Home > Backend Development > PHP Tutorial > SQL报错,You have an error in your SQL syntax; check the manual that corresponds to

SQL报错,You have an error in your SQL syntax; check the manual that corresponds to

WBOY
Release: 2016-06-23 13:49:42
Original
4073 people have browsed it

SQL报错了,
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1---Resource id #9----SELECT imei from messagelog where mac in () 
PHP代码:

$mac.="'".$value."',";$listimei = $db->query("SELECT imei from messagelog where mac in ($mac) ")->fetchList();
Copy after login

不知道哪个地方有问题,求大神帮忙


回复讨论(解决方案)

试试

$listimei = $db->query("SELECT imei from messagelog where mac in ('$value') ")->fetchList();
Copy after login

你的 $mac 为空
实际执行的是 SELECT imei from messagelog where mac in ( )
这就要出错了:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' 

$mac最后多一个逗号

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template