jobs1109 Posted October 10, 2011 Share Posted October 10, 2011 Hi everyone, I am having a problem with using quotation marks / apostrophe with php and mysql. If I enter the following lines in mysql. "user's resume" when I do a query from mysql i get back " User\'s resume" it's adding a slash before the apostrophe. How can I fix this ? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/248837-using-quotation-marks-with-php-and-mysql/ Share on other sites More sharing options...
AbraCadaver Posted October 10, 2011 Share Posted October 10, 2011 mysql_real_escape_string Quote Link to comment https://forums.phpfreaks.com/topic/248837-using-quotation-marks-with-php-and-mysql/#findComment-1277896 Share on other sites More sharing options...
Psycho Posted October 10, 2011 Share Posted October 10, 2011 You state that you are getting the slash on the returned data. I think your problem is that you are probably using mysql_real_escape_string() (or possibly addslashes()). But the problem is that your server probably has magic quotes enabled. So, when you send data through POST/GET/COOKIE the server is automatically adding slashes. So, when you then run the input through mysql_real_escape_string() it is escaping the slashes to make them part of the data. Magic quotes are deprecated and should be disabled. If you cannot disable them through the ini file, then you should add code to dynamically remove them at run time. http://php.net/manual/en/security.magicquotes.disabling.php Quote Link to comment https://forums.phpfreaks.com/topic/248837-using-quotation-marks-with-php-and-mysql/#findComment-1277898 Share on other sites More sharing options...
AbraCadaver Posted October 10, 2011 Share Posted October 10, 2011 Hmmm... Would help if I read the entire post Quote Link to comment https://forums.phpfreaks.com/topic/248837-using-quotation-marks-with-php-and-mysql/#findComment-1277900 Share on other sites More sharing options...
jobs1109 Posted October 10, 2011 Author Share Posted October 10, 2011 Hi everyone i got it solved. I just turned off magic quotes in php.ini Thanks Quote Link to comment https://forums.phpfreaks.com/topic/248837-using-quotation-marks-with-php-and-mysql/#findComment-1277907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.