note 22788 added to function.addslashes
| From: | php-general at lists dot php dot net | Date: | Sun, 30 Jun 2002 03:19:46 +0000 |
| Subject: | note 22788 added to function.addslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32428@lists.php.net to get a copy of this message | ||
I think its a big prob that addslashes keeps adding slashes if you run it over and over on the
same var. For ex. If magic quotes are on (witch is usually always) this would happen.. open this
script with ?log=joes_dog
echo $_GET[log]
would print joe/s_dog
but if you insert that to a db, and use addslashes like every tutorial says out there
You end up
with a joe//s_dog". There needs to be an optional pram to skip if already slashed, the
func below isnt the best way cuz if the data inside has / in it for some reason it would think
addslashes has gotten to it.. An internal function change is really the only easy way to fix the
slash fight.
Heres a basic func that tell if the info is already slashed..
function is_slashed($data) {
if(stripslashes($data) == $data) {
return 0;
} else {
return 1;
}
}
--
http://www.php.net/manual/en/function.addslashes.php
http://master.php.net/manage/user-notes.php?action=edit+22788
http://master.php.net/manage/user-notes.php?action=delete+22788
http://master.php.net/manage/user-notes.php?action=reject+22788