Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.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 未找到列:1054列位于';其中第'条;_Php_Mysql_Sql_Forms - Fatal编程技术网

Php 未找到列:1054列位于';其中第'条;

Php 未找到列:1054列位于';其中第'条;,php,mysql,sql,forms,Php,Mysql,Sql,Forms,我想检查地址记录是否已经存在 我使用的是简单查询,它应该返回数据库中已有记录的值,但它使用关键字来搜索列 这是我的代码: $address=$_POST['billing_address_2']; $query = "select * from shipping_info WHERE address=$address"; $st2 = $con->prepare($query); $st2->execute(); 这是确切的错误消息: 未找到列

我想检查地址记录是否已经存在 我使用的是简单查询,它应该返回数据库中已有记录的值,但它使用关键字来搜索列 这是我的代码:

$address=$_POST['billing_address_2'];
$query = "select * from shipping_info WHERE address=$address";
$st2  = $con->prepare($query);
        $st2->execute();
这是确切的错误消息: 未找到列:“where子句”中的1054未知列“ffff”。 注:
“ffff”是$address变量的值

错误是因为您没有在
$address
周围加引号

但您应该使用参数化查询

mysqli:

$address=$_POST['billing_address_2'];
$query = "select * from shipping_info WHERE address=?";
$st2  = $con->prepare($query);
$st2->bind_param("s", $address);
$st2->execute();
PDO:


使用参数@Barmer谢谢你的回答,我是php新手
$address=$_POST['billing_address_2'];
$query = "select * from shipping_info WHERE address=:address";
$st2  = $con->prepare($query);
$st2->bindParam(":address", $address);
$st2->execute();