Dimitri Vorontzov 0 Posted November 22, 2012 Report 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 Quote Link to post Share on other sites
Edward 108 Posted November 22, 2012 Report 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 Quote Link to post Share on other sites
Dimitri Vorontzov 0 Posted November 22, 2012 Author Report 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 Quote Link to post Share on other sites
Edward 108 Posted November 23, 2012 Report Share Posted November 23, 2012 Run the phpinfo() function on your script and check that the Magic Quotes value is off. 1 Quote Link to post Share on other sites
Dimitri Vorontzov 0 Posted November 23, 2012 Author Report 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. Quote Link to post Share on other sites
Larry 433 Posted November 25, 2012 Report 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 Quote Link to post Share on other sites
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.
Note: Your post will require moderator approval before it will be visible.