Skip to the content
moneyslow.com
  • link
  • vps
  • all
  • about

php mysql 插入单引号报错right syntax to use near 's formula

moneyslow | 2022-04-07
怀旧70年代的老照片(1)

解决办法,需要用addslashes函数处理一下,代码:

$a = "a'b";
$sql = "INSERT INTO `aa`(`txt`) VALUES ('$a')";
$result = mysql_query($sql);
//-----执行报错 
使用addslashes() 函数 在预定义字符之前添加反斜杠的字符串
$a = addslashes($a);

解决了。

Categories: 最新文章 标签:php

文章导航

← Warning: Use of undefined constant CHARSET - assumed ‘CHARSET’ (this will throw an Error in a future version of PHP)解决办法
只取出字符串长度大于某一长度的行(比如用于删除一些垃圾行的情况) →
© 2023 moneyslow.com
京ICP备11047313号-19