错误描述: 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
展开阅读全文

今天用mysqld insert的时候,出现以下错误:

错误描述: 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 

原来是文章内容的单双银号的问题引发的插入数据库失败,使用了好多方法,最后终于有一个满意的解决方法:

使用php addslashes即可

<?php
$str = "Who's Bill Gates?";
echo $str . " This is not safe in a database query.<br>";
echo addslashes($str) . " This is safe in a database query.";
?>