Jump to content
Larry Ullman's Book Forums

Chapter 11, Pg. 300: Backslashes Before Apostrophes In .Txt File


Recommended Posts

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

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.

  • Upvote 1
Link to comment
Share on other sites

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

 Share

×
×
  • Create New...