Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何删除这些警告_Php_Wordpress - Fatal编程技术网

Php 如何删除这些警告

Php 如何删除这些警告,php,wordpress,Php,Wordpress,我正在wordpress中使用Allow PHP in Post和Pages插件,通过它我集成了一个表单 警告:mysql\u real\u escape\u string():21不是第789行的..wp includes\wp-db.php中的有效mysql链接资源 警告:mysql_error():21不是第1102行的..wp includes\wp-db.php中的有效mysql链接资源 我表格的代码在这里 $con = mysql_connect("localhost","r

我正在wordpress中使用Allow PHP in Post和Pages插件,通过它我集成了一个表单

警告:mysql\u real\u escape\u string():21不是第789行的..wp includes\wp-db.php中的有效mysql链接资源

警告:mysql_error():21不是第1102行的..wp includes\wp-db.php中的有效mysql链接资源

我表格的代码在这里

    $con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("form", $con);
$sql="INSERT INTO data (consignor,consignee, conveyance, origin, entry_port, importing_country, container_no, package_no, package_type, product_name, bot_name, quantity, certify, add_declaration, date,treatment, duration_temprature, concentration, add_information, inspector_name, place, name_designation, issue_date)
VALUES
('$_POST[exporter]', '$_POST[importer]', '$_POST[conveyance]', '$_POST[origin]', '$_POST[dpoe]', '$_POST[impcon]', '$_POST[container]', '$_POST[nopk]', '$_POST[tyop]', '$_POST[name]', '$_POST[botname]', '$_POST[quantity]', '$_POST[certify]', '$_POST[declaration]', '$_POST[date]', '$_POST[treatment]', '$_POST[dutemp]', '$_POST[concen]', '$_POST[adinfo]', '$_POST[insname]', '$_POST[place]', '$_POST[namedesg]', '$_POST[dateissue]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Form Submitted";

mysql_close($con);
?>
<form action="#" method="post">
<table height ="200px" width="676" border="1" cellspacing="0" cellpadding="0">

<tr>
<td colspan="7" valign="top" width="676"> 
</td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">1. Exporter/Consignor (Name & Address)<br/>
<input type="text" name="exporter" />
</td>
<td colspan="4" valign="top" width="356">2. Importer/Consignee (Name & Address)
 <input type="text" name="importer" />
</td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">3. Declared means of conveyance
<input type="text" name="conveyance" /></td>
<td colspan="4" valign="top" width="356">4. Place of Origin<br/>
<input type="text" name="origin" /></td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">5. Declared Port of entry<br/>
<input type="text" name="dpoe" /></td>
<td colspan="4" valign="top" width="356">6. Department of Plant Protection of Pakistan To Plant Protection Organization Of (importing country)<br/>
<input type="text" name="impcon" />
</td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">7. Distinguishing marks/Container No./ Seal No.<br/>
<input type="text" name="container" /></td>
<td colspan="3" valign="top" width="172">8. No. of Packages<br/>
<input type="text" name="nopk" />
</td>
<td valign="top" width="184">9. Type of packages<br/>
<input type="text" name="tyop" /></td>
</tr>
<tr>
<td valign="top" width="221">10. Name of Product<br/>
<input type="text" name="name" /></td>
<td colspan="4" valign="top" width="233">11. Botanical name of plant
<br/>
<input type="text" name="botname" />
</td>
<td colspan="2" valign="top" width="221">12. Quantity<br/>
<input type="text" name="quantity" /></td>
</tr>
<tr>
<td colspan="7" valign="top" width="676">13. This is to certify that the plants, plant products or other regulated articles described herein above have been inspected and/ or tested according to appropriate official procedures and are considered to be free from the quarantine pests, specified by the importing contracting party and to conform with the current phytosanitary requirements  of the importing contracting party including those for regulated non-quarantine pests.<br/>
<input type="checkbox" name="certify" value="Yes"/> Yes
<input type="checkbox" name="certify" value="No"/> No<br/>
 </td>
</tr>
<tr>
<td colspan="7" valign="top" width="676">14. Additional Declaration
<br/>
<textarea name="declaration" cols="40" rows="2">Please limit your response to 200 characters.</textarea><br />
</td>
</tr>
<tr>
<td colspan="7" valign="top" width="676" bgcolor="grey">
<p align="center"><strong>Disinfestations and / or disinfection treatment </strong></p>
</td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">15. Date
<br/>
<input type="text" name="date" /></td>
<td colspan="4" valign="top" width="356">16. Treatment<br/>
<input type="text" name="treatment" /></td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">17. Duration & Temperature
<br/>
<input type="text" name="dutemp" />
</td>
<td colspan="4" valign="top" width="356">18. Concentration<br/>
<input type="text" name="concen" /></td>
</tr>
<tr>
<td colspan="3" valign="top" width="320">19. Additional Information
<br/>
<textarea name="adinfo" cols="40" rows="2">Please limit your response to 200 characters.</textarea><br />
</td>
<td colspan="4" valign="top" width="356">20. Name of Inspector<br/>
<input type="text" name="insname" /></td>
</tr>
<tr>
<td colspan="2" valign="top" width="240">21. Stamps of Organization
<br></br><br></br>
 </td>
<td rowspan="2" colspan="2" valign="top" width="168">
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong> </strong></p>
<p align="right"><strong>PROGRESSIVE </strong></p>
</td>
<td rowspan="2" colspan="3" valign="top" width="340">23. Place of issue<br/>
<input type="text" name="place" /><br/>
24. Signature__________________________<br/><br></br>
25. Name and designation of authorized officer
<input type="text" name="namedesg" /> <br/><br/>
26. Date <br/>
<input type="text" name="dateissue" /></p></td>
</tr>
<tr>
<td colspan="2" valign="top" width="240">22. No financial liability with respect to this certificate shall attach to department of plant protection or to any of its officers or representatives
<br></br></td>
</tr>
<tr>
<td width="221" border="0"></td>
<td width="19"></td>
<td width="80"></td>
<td width="48"><input type="submit" value="Submit Form" /></td>
<td width="47"><input type="reset" value="Reset" /></td>
<td width="137"></td>
<td width="220"></td>
</tr>
<tr><td></td>
<td></td>
<td></td>
<td align="right"></td>
</tr>
</table>
</form>
</html>
$con=mysql\u connect(“本地主机”、“根目录”、“根目录”);
如果(!$con)
{
die('无法连接:'.mysql_error());
}
mysql_select_db(“表单”$con);
$sql=“插入数据(发货人、收货人、运输工具、原产地、入境口岸、进口国、集装箱号、包装号、包装类型、产品名称、运输工具名称、数量、认证、添加声明、日期、处理、持续时间、温度、浓度、添加信息、检查员名称、地点、名称、名称、发布日期)
价值观
“有关邮政(运输工具)”,“邮政(运输工具)”,“邮政(原产地)后,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,美元邮政","邮政署名称","邮政署地点","邮政署名称","邮政署日期",;
if(!mysql_query($sql,$con))
{
die('Error:'.mysql_Error());
}
回应“提交的表格”;
mysql_close($con);
?>
1.出口商/发货人(名称和地址)
2.进口商/收货人(名称和地址)   3.申报的运输工具 4.原产地
5.申报的入境港
6.巴基斯坦植保部致(进口国)植保组织
7.识别标志/集装箱编号/封号
8.包裹数量
9.包装类型
10.产品名称
11.植物的植物学名称
12.数量
13.兹证明上述植物、植物产品或其他受管制物品已按照适当的官方程序进行检验和/或测试,并被视为不存在进口缔约方规定的检疫性有害生物,并符合当前的植物检疫要求进口缔约方的,包括受管制的非检疫性有害生物。
对 否
  14.补充声明
请将您的回复限制在200个字符以内。

杀虫和/或消毒处理

15.日期
16.治疗
17.持续时间和温度
18.浓度
19.补充资料
请将您的回复限制在200个字符以内。
20.检查员姓名
21.组织邮票



 

渐进式

23.发行地点

24.签名
25.获授权人员的姓名和名称

26.日期

22.与本证书有关的任何财务责任均不属于植物保护部或其任何官员或代表


在wordpress中,您不能使用普通的mysql系统调用数据库。您需要通过

global $wpdb;
有关更多示例,请参见此链接

编辑

尝试将PHP调用代码更改为如下内容

edit2

添加一些代码以防止sql攻击。基本上,将它们放入变量并转义

<?php
//no need to connect & close to db. it's done automatically by wpdb.
// the database MUST be the same with wordpress database. only different tables.
global $wpdb;

//protect your codes from attacks.
@ isset($_POST['exporter']) ? $exporter=$wpdb->escape($_POST['exporter']) : $exporter='';
@ isset($_POST['importer']) ? $importer=$wpdb->escape($_POST['importer']) : $importer='';
@ isset($_POST['conveyance']) ? $conveyance=$wpdb->escape($_POST['conveyance']) : $conveyance='';
//....
@ isset($_POST['dateissue']) ? $dateissue=$wpdb->escape($_POST['dateissue']) : $dateissue='';


if (!$wpdb->insert('data',
                        array(
                            'consignor'=>$exporter
                            ,'consignee'=>$importer
                            ,'conveyance'=>$conveyance
                            //...
                            ,'issue_date'=>$dateissue
                        ))) exit;
else {echo 'Form Submitted';}
?>

还显示了“提交的表单”在表单顶部和表中存储的数据。有人能帮我解决这个问题吗???那么我可以用全局$wpdb替换所有db变量吗?我可以用纯HTML插件单独集成HTML表单吗?不确定纯HTML插件的意思。但你的错误只是因为你试图通过wordpress访问db,而不是使用wpdb。如果您使用$wpdb访问表,那么wordpress就可以了。任何HTMLs都应该是正常的。从表单中删除#并使其为空,这样它就变成了……此表单中数据的新位置是什么?