Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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-mysql多个where编码_Php - Fatal编程技术网

php-mysql多个where编码

php-mysql多个where编码,php,Php,输出:-当且仅当同时提供了名字和电话号码时,它将显示正确的输出,否则它将显示一些随机值。如果您有一些客户没有名字或电话,并且相应的表单值也为空,则您将得到错误的响应。您应该检查表单数据: $customer_phonenumber = $_POST['customer_phonenumber']; $customer_firstname = $_POST['customer_firstname']; $sql =mysql_query( "SELECT * FROM tbl_customer

输出:-当且仅当同时提供了名字和电话号码时,它将显示正确的输出,否则它将显示一些随机值。

如果您有一些客户没有名字或电话,并且相应的表单值也为空,则您将得到错误的响应。您应该检查表单数据:

$customer_phonenumber = $_POST['customer_phonenumber'];
$customer_firstname = $_POST['customer_firstname'];


$sql =mysql_query( "SELECT * FROM tbl_customer WHERE customer_firstname = '$customer_firstname' OR customer_phonenumber = '$customer_phonenumber' ") or die(mysql_error());



$sqlarray=mysql_fetch_array($sql);

如果您有一些客户没有名字或电话,并且相应的表单值也为空,那么您将得到错误的响应。您应该检查表单数据:

$customer_phonenumber = $_POST['customer_phonenumber'];
$customer_firstname = $_POST['customer_firstname'];


$sql =mysql_query( "SELECT * FROM tbl_customer WHERE customer_firstname = '$customer_firstname' OR customer_phonenumber = '$customer_phonenumber' ") or die(mysql_error());



$sqlarray=mysql_fetch_array($sql);

然后使用
而不是
,如果您希望两者都为真。还可以尝试对代码实现一些安全性。在查询中检查它们之前,请检查它们是否已设置。切换到使用
mysqli
函数,因为
mysql
函数已被弃用。出于对服务器的热爱,不要在数据库查询中使用
$\u POST
变量而不首先转义它们,你只是在请求注入攻击。你能将你的问题表述为实际问题吗?谢谢GeoffAtkinsif&如果我使用mysql\u real\u escape\u string,它将解决这个问题,我对php是新手。我很快就开始了pdo课程,我将全部改为pdo,然后使用
而不是
,如果您希望这两个都是真的。还可以尝试对代码实现一些安全性。在查询中检查它们之前,请检查它们是否已设置。切换到使用
mysqli
函数,因为
mysql
函数已被弃用。出于对服务器的热爱,不要在数据库查询中使用
$\u POST
变量而不首先转义它们,你只是在请求注入攻击。你能将你的问题表述为实际问题吗?谢谢GeoffAtkinsif&如果我使用mysql\u real\u escape\u string,它将解决这个问题,我对php是新手。我很快就开始为pdo上课了,我将全部改为pdo