MySQLi INSERT出错

时间:2013-07-24 20:57:34

标签: php mysqli

我有查询,我再次尝试从pop3帐户传递到mysql数据库:

mysqli_query($con,"INSERT INTO procesa_emails (body_mail, uid_message, fecha, from, to, subject, message_id) VALUES ('".mysqli_real_escape_string($con,htmlentities(str_replace("'","",str_replace('"','',$message))))."','".mysqli_real_escape_string($con,htmlentities($uid_mess))."','".mysqli_real_escape_string($con,htmlentities($fecha))."','".mysqli_real_escape_string($con,htmlentities($from))."','".mysqli_real_escape_string($con,htmlentities($to))."','".mysqli_real_escape_string($con,htmlentities($subject))."','".mysqli_real_escape_string($con,htmlentities($mui))."')")or die(mysqli_error($con));

但它让我回答:

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 'from, to, subject, message_id) 

我尝试使用str_replace(“'”,“”,str_replace('“'。'''))但它也不起作用

1 个答案:

答案 0 :(得分:1)

FROMreserved keyword。因此,如果要在查询中使用它,则需要将其包装在反引号中,如下所示:

mysqli_query($con,"
INSERT INTO procesa_emails (body_mail, uid_message, fecha, `from`, ...

希望这有帮助!