dongziduo9762 2013-07-24 20:57
浏览 18
已采纳

MySQLi INSERT出错

I have ths query, again i'm trying to pass from pop3 account to mysql database:

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));

But It returns me:

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) 

I tried with str_replace("'","",str_replace('"'.'')) But It also doesn't work

  • 写回答

1条回答 默认 最新

  • dsm13698679318 2014-05-03 14:40
    关注

    FROM is a reserved keyword. So, if you want to use that inside your query, you need to wrap it in backticks, like so:

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

    Hope this helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥200 求能开发抖音自动回复卡片的软件
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。