MYSQL PHP在WHERE IN()CLAUSE中无法正常工作

时间:2017-12-08 11:48:27

标签: php mysql mysqli

$ci = implode('&#39,&#39', $_GET['city']);

$res = mysqli_query($link,"SELECT * FROM data WHERE (date BETWEEN '$dd1' AND '$dd2') AND (city IN('$ci')) ORDER BY id DESC")or die (mysql_error());

如果我echo $ci而不是显示值JND','RJT','ABD但不使用变量

如果我直接放置city IN ('JND','RJT','ABD')它有效..

使用可靠的不执行查询

1 个答案:

答案 0 :(得分:0)

尝试检查您的查询文字

$ci = implode("','", $_GET['city']);

$query = "SELECT * FROM data WHERE (date BETWEEN '$dd1' AND '$dd2') AND (city IN('$ci')) ORDER BY id DESC";

echo $query;

$res = mysqli_query($link,$query)or die (mysql_error());