[英]PHP array in mySQL query: “Unknown column”
I cannot figure out what's wrong with my query. 我无法弄清楚查询出了什么问题。
I'm trying to use a PHP array in it. 我正在尝试在其中使用PHP数组。
Array: 数组:
$devices2 = implode(", ", $devices);
//echo $devices2 result: BlåAvformning, GulAvformning
SQL 的SQL
$query = "SELECT * FROM table
WHERE myColum IN($devices2)";
Error: 错误:
Unknown column 'BlåAvformning' in 'where clause' “ where子句”中的未知列“BlåAvformning”
I have tried adding quotes, and searched several likely questions, but I cannot get this to work! 我尝试添加引号,并搜索了几个可能的问题,但是我无法使它正常工作!
Why? 为什么?
UPDATE 更新
As commented I needed more quotes: 正如评论我需要更多的报价:
$devices2 = "'".implode("', '", $devices)."'";
As commented, i needed more qutoes: 如所评论,我需要更多的qutoes:
$devices2 = "'".implode("', '", $devices)."'";
Credit to: Mark Baker 归功于:Mark Baker
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.