MYSQL 写入异常讯息

WBOY
Release: 2016-06-13 12:21:01
Original
1049 people have browsed it

MYSQL 写入错误讯息

<br />$value = array ();<br /><br />foreach ($all as $cust) {<br />	$value[] = " ('{$cust['id']}', '{$cust['last']}') ";<br />}<br />		<br />echo $query = " insert into cust (cust_id,last) values ". implode(", ", $value);<br />$db->query($query);<br />
Copy after login


会出现
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
请问哪里写错了?
------解决思路----------------------
字段列数和值的数量不对应
看你数据,你可能是要批量插入
先将你的 sql 输出看一下,应该是你组织sql错了


------解决思路----------------------
我要你贴出
$value = array ();<br /> <br />foreach ($all as $cust) {<br />    $value[] = " ('{$cust['id']}', '{$cust['last']}') ";<br />}<br />         <br />echo $query = " insert into cust (cust_id,last) values ". implode(", ", $value);
Copy after login

的结果,你贴了吗?
如果是 insert into cust (cust_id,last) values ()
那就是说 $all 是空数组

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