开发者

Insert ' and " into mysql using php [duplicate]

开发者 https://www.devze.com 2023-03-18 03:10 出处:网络
This question already has answers here: Clo开发者_JS百科sed 11 years ago. Possible Duplicate: Best way to stop SQL Injection in PHP
This question already has answers here: Clo开发者_JS百科sed 11 years ago.

Possible Duplicate:

Best way to stop SQL Injection in PHP

I am trying to insert ' sign and " in a mysql table using php. But the content has this two signs I get a mysql error.

 $comment="I like '''' it so ""much"" Jaan";
mysql_query("INSERT INTO `comments` (`id` ,`name` ,`date` ,`comment`) VALUES ('', '$name', '$date', '$comment')");

above one is an example. Whenever an user insert ' or " in his comment the problem begins. I know about mysql_real_escape_string() but i dont want to use this. Bcz My comments are already filtered. Please tell me how I can Insert comment with those syntax. every suggestions are welcome.


Escape every string variable with mysql_real_escape_string().

0

精彩评论

暂无评论...
验证码 换一张
取 消