Dimitri Vorontzov Posted November 22, 2012 Share Posted November 22, 2012 Hello Forum - hello Larry - - I'm working on a Mac, OS X Version 10.5.8. When I write a quote that contains an apostrophe to quotes.txt file, for example -- I've wasted my hours. - Leonardo da Vinci -- somehow a backslash appears before the apostrophe in the text file, and the same quote inside quotes.txt looks like this: I\'ve wasted my hours. - Leonardo da Vinci When I get the same quote from the text file via php back to the browser in view_quote.php, the backslash is displayed. The backslash also appears before double quotes: \"I've wasted my hours.\" - Leonardo da Vinci Why do backslashes appear, and what can I do to remove them? Thank you! - Dimitri Vorontzov Link to comment Share on other sites More sharing options...
Edward Posted November 22, 2012 Share Posted November 22, 2012 Its because your magic quotes are enabled on the server therefore the characters are escaped with slashes. You can disable magic quotesin the php.ini file and check for its current status using phpinfo function. To remove escape characters from your current data use stripslashes php function which returns a string. 1 Link to comment Share on other sites More sharing options...
Dimitri Vorontzov Posted November 22, 2012 Author Share Posted November 22, 2012 Thank you, Edward. Actually, I was pretty sure I disabled magic quotes - but probably I didn't do it correctly. Here's the line of code I used to disable them in php.ini: magic_quotes_gpc = Off I assumed, that line should have disabled them for all user-submitted data. I've got PHP 5.3, by the way. Still, the \' remain. Would appreciate more of your input. - Dimitri Vorontzov Link to comment Share on other sites More sharing options...
Edward Posted November 23, 2012 Share Posted November 23, 2012 Run the phpinfo() function on your script and check that the Magic Quotes value is off. 1 Link to comment Share on other sites More sharing options...
Dimitri Vorontzov Posted November 23, 2012 Author Share Posted November 23, 2012 It's On in the phpinfo(), even though it's set to Off in php.ini - what am I missing? I'm using MAMP, I go to MAMP/conf/php5.3/php.ini - and there's a line in it that I personally typed: magic_quotes_gpc = Off Would appreciate your help. Link to comment Share on other sites More sharing options...
Larry Posted November 25, 2012 Share Posted November 25, 2012 Yeah, MAMP is tricky. You actually have to edit the INI file through the MAMP application. It uses a template that it regenerates every time, which is why your change is not taking effect. 1 Link to comment Share on other sites More sharing options...
Recommended Posts