note 26526 added to function.addslashes

From: Date: Sun, 03 Nov 2002 13:12:32 +0000
Subject: note 26526 added to function.addslashes
Groups: php.notes 
Request: Send a blank email to php-notes+get-38921@lists.php.net to get a copy of this message
If you want to display the data posted by a form, and insert it in a mysql database, the slashes will not be stripped by stripslashes if magic_quotes_gpc is enabled. i.e. $data = addslashes($data); \\ insert into mysql $sql.. ; \\stripslashes to display data $data = stripslashes($data); echo "$data"; Will display the data posted from the form WITH the slashes, it doesn't work. It will work if you do it like this: // deletes the slashes automaticly inserted if magic_quotes_gpc is set to 1 $displaydata = stripslashes($data); // adds the slashes before insertion in the database $data = addslashes($data); // insert into mysql $sql.. ; echo "$displaydata"; Will display the data WITHOUT the slashes, but the data is inserted into the mysql database WITH the slashes. -- http://www.php.net/manual/en/function.addslashes.php http://master.php.net/manage/user-notes.php?action=edit+26526 http://master.php.net/manage/user-notes.php?action=delete+26526 http://master.php.net/manage/user-notes.php?action=reject+26526

« previous php.notes (#38921) next »