作者lottemarines (一平)
看板PHP
标题[请益] sql语法出现错误
时间Thu Oct 18 15:59:15 2007
各位先进
小弟的程式是这样写的
$str="UPDATE `phpbb_posts_text` SET `post_text` = '$c'
WHERE `post_id` = $post_id1";
mysql_query($str,$link) or die("error1");
断行是在这里塞不下,所以才断行,原本的程式没有断行
问题在於 $c 的内容平常都正常,但如果字串$C出现了 ' 符号,就会导致无法写入资料库
出现 error1 的提示。
请问我要怎麽去处理 $c 让他可以写入 ' 符号。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.130.176.207
1F:推 dspswen:不知道 str_replace 可不可以解决这个问题 10/18 16:43
2F:→ dspswen:将 ' replace 成 ' 10/18 16:44
3F:→ buganini:sql injection... 10/18 18:08
4F:推 JoeHorn:前面加一行 $c = addslashes($c); 10/19 01:11