Page 1 of 1

MySQL auto stripslashes?

Posted: Sat Jan 14, 2006 10:10 pm
by php_wiz_kid
In a common files used at the top of every page I have a little script that add slashes to every $_POST, $_GET, and $_COOKE variable. This is similar to what's used in PHPBB. My question is does MySQL automatically remove the salshes on insert into the database? When I step through the code it seems that the slashes stay right up to the moment it gets inserted. Should I worry about this or should I just let it do its thing?

Posted: Sat Jan 14, 2006 10:17 pm
by feyd
It expects the information to be slashed, because of delimiting characters it uses, so yes, it stripslashes()

Posted: Sat Jan 14, 2006 10:27 pm
by php_wiz_kid
Should the data in the database be slashed or is that something I shouldn't worry about?

Posted: Sat Jan 14, 2006 10:31 pm
by feyd
the data stored will not be slashed unless you do a double addslashes, which just wastes bytes.. :P

Posted: Sat Jan 14, 2006 10:37 pm
by php_wiz_kid
Alright, thanks, that's all I needed to know! :D

Posted: Sun Jan 15, 2006 11:51 am
by Ambush Commander
Note that it is probably a better idea to use mysql_real_escape_string() rather than addslashes().