Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.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_Mysql_Postgresql - Fatal编程技术网

Php 错误:子句条目中缺少

Php 错误:子句条目中缺少,php,mysql,postgresql,Php,Mysql,Postgresql,我是php和postgres sql的新手。 我有这个问题:“pg_query():查询失败:错误:表“manteau”的子句条目中缺少^ $adresse=pg_escape_string($_POST['mail_user']); if(isset($_POST['mail_user'])) { $query="INSERT INTO newusers2 (email) VALUES ($adresse)"; pg_query($con,$query); } with m

我是php和postgres sql的新手。 我有这个问题:“pg_query():查询失败:错误:表“manteau”的子句条目中缺少^

$adresse=pg_escape_string($_POST['mail_user']);
if(isset($_POST['mail_user']))
{ 
    $query="INSERT INTO newusers2 (email) VALUES ($adresse)";
    pg_query($con,$query);
}
with mail_user=我的地址email manteau.b。。。 我的表(newusers2)非常简单,只有一列(email)

有人能帮我解答这个问题吗


谢谢

将值
$adrese
放在引号内:

$query="INSERT INTO newusers2 (email) VALUES ('$adresse')";

除了由于缺少引用而导致错误之外,您的代码也非常不安全

$query="INSERT INTO newusers2 (email) VALUES ($adresse)";
pg_query($con,$query);
想象一下,如果有人提交了
”;从newusers2中删除--作为他们的地址?哎呀,你的用户表出来了

有关详细信息,请参阅和

用于解决此问题。很简单:

$query='INSERT INTO newusers2 (email) VALUES ($1)';
pg_query($con,$query,array($adresse));

(请注意,PHP中的新代码确实应该使用PDO)。

当值是字符串时,您需要使用引号“$ADRESE”,当值是数字时,您不需要引号,只要$numThanks就可以了。现在可以了!我们不应该删除mysql标签吗?@Md.SahadatHossain是一个非常糟糕的建议。特别是对于新用户,请将其指向参数化语句(“准备好的语句”)。