我有一个表:语法错误尝试使用时,“秀”的字段名中插入一行
up_rel
> |--id--|--uid--|--pid--|--show--|
我这样做插入序列:
$icat_sth = $dbh->prepare("INSERT INTO product_category (name, parent) VALUES(:name, :parent)");
$icat_sth->bindParam(':name', $post['cat_name']);
$icat_sth->bindParam(':parent', $post['parent_category']);
$icat_sth->execute();
$pid = $dbh->lastInsertId();
$rel_sth = $dbh->prepare("INSERT INTO up_rel (uid, pid, show) VALUES(:uid, :pid, :show)");
$rel_sth->bindParam(':uid', $uid);
$rel_sth->bindParam(':pid', $pid);
$rel_sth->bindParam(':show', '1');
$rel_sth->execute();
echo $dbh->lastInsertId();
先插入到产品类别的那张光滑但下一个插入返回一个错误:
1064 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 'show) VALUES(?, ?, ?)' at line 1
如果我从插入删除显示它的工作。
我已经尝试把值在(:uid, :pid, 1)
和在我已经引用它的绑定而不是。
有什么我失踪?
$ uid在脚本的前面设置.. $ pid是从第一个插入的最后一个插入标识中设置的。如果我删除节目,它的作品..? – 2013-03-11 04:33:15