 |
 |
php adding slashes?
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status:
Offline
|
|
I use PHP to add news entries and allow others to post comments on my website. The visitors can enter text in to a form and submit it for addition to a page. The problem I've found is that when I write the information to the file, single and double quotes are automatically escaped and I'm not sure how to prevent it from doing so. There is no reason for the quotes to be escaped. I'm using fwrite to write the string to a file handle. How do I stop PHP from automatically adding the \'s???
|
|
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by milf:
I use PHP to add news entries and allow others to post comments on my website. The visitors can enter text in to a form and submit it for addition to a page. The problem I've found is that when I write the information to the file, single and double quotes are automatically escaped and I'm not sure how to prevent it from doing so. There is no reason for the quotes to be escaped. I'm using fwrite to write the string to a file handle. How do I stop PHP from automatically adding the \'s???
$string = stripslashes($string);
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status:
Offline
|
|
Where do the slashes come from in the first place though? Are they automatically added by php? And if so, when, why, and how?
|
|
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status:
Offline
|
|
Okay, I did a little more research and finally found my answer. PHP auto adding slashes is a feature built in to the language. It automatically adds slashes to data submitted as HTML form data or cookies. That, to me, is annoying, although I'm sure there are plenty of people that such a feature benefits. Thankfully, there is a way to turn this feature of. In the PHP.ini file, there is an option for magic_quotes_gpc. If this is on, everything is automatically escaped (slashed). Otherwise, if it is off, things will be as normal.
Just thought I'd pass the information along for other curious minds. 
|
|
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |