0

如何正确编写此代码.....在这里我使用了 3 'AND' 及其显示错误...请帮助我...

 if(isset($_GET['datepicker'])){
 $mydate = mysql_real_escape_string($_GET['datepicker']);
 }
 if(isset($_GET['cityText'])){
 $city1 = mysql_real_escape_string($_GET['cityText']);
 }

 if(isset($_GET['categoryValue'])){
$category1 = mysql_real_escape_string($_GET['CategoryValue']);
}

 $sql = "SELECT * FROM general WHERE gcity = '$city1' AND day1 = '$mydate' AND category = '$category1'"
4

2 回答 2

2

您拼错了变量名,categoryValue 写了一次,没有首字母大写,第二次写了大写字母。变量名区分大小写。

代替

if(isset($_GET['categoryValue'])){
$category1 = mysql_real_escape_string($_GET['CategoryValue']);
}

if(isset($_GET['categoryValue'])){
    $category1 = mysql_real_escape_string($_GET['categoryValue']);
}
于 2012-09-06T11:55:22.220 回答
1

除了在其中声明 php 变量外,查询似乎没有问题:

试试这个方法:

$sql = "SELECT * FROM general WHERE gcity = '".$city1."' AND day1 = '".$mydate."' AND category = '".$category1."'"

于 2012-09-06T11:55:40.887 回答