virtuexru Posted March 31, 2007 Share Posted March 31, 2007 OK, so I have users write something. Then input it to a "wall post".. kinda like a flat message board. However, since I use mysql_real_escape_string(); for the $_POST variable, when they use the ' character, posts come out jarbled like this: " couldn\'t understand it, I\'m totally new to it" Anyway to fix this or workaround? Link to comment https://forums.phpfreaks.com/topic/45056-question-about-mysql_real_escape_string/ Share on other sites More sharing options...
genericnumber1 Posted March 31, 2007 Share Posted March 31, 2007 That would be magic_quotes, a php.ini setting... you can turn this off or run stripslashes before you use mysql_real_escape_string() <?php $variable = $_POST['variable']; if(get_magic_quotes_gpc()) // For portability { $variable = stripslashes($variable); } $variable = mysql_real_escape_string($variable); ?> Link to comment https://forums.phpfreaks.com/topic/45056-question-about-mysql_real_escape_string/#findComment-218731 Share on other sites More sharing options...
shocker-z Posted March 31, 2007 Share Posted March 31, 2007 That would be magic_quotes, a php.ini setting... you can turn this off or run stripslashes before you use mysql_real_escape_string() <?php $variable = $_POST['variable']; if(get_magic_quotes_gpc()) // For portability { $variable = stripslashes($variable); } $variable = mysql_real_escape_string($variable); ?> You mean stripslashes after not before? because before there are no slashes added, mysql_real_escape_string adds the slashes.. but will remove the slashes when you echo the data back on what ever page you do that on.. regards Liam Link to comment https://forums.phpfreaks.com/topic/45056-question-about-mysql_real_escape_string/#findComment-218757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.