Page 1 of 1

how to avoide the special characters in php

Posted: Fri Oct 05, 2007 6:52 am
by qumar
hi,
how to avoide the special characters in php. like
single codes, double code, slashes, question marks etc.
please help to me.give some idea.

thanks,
qumar.

Posted: Fri Oct 05, 2007 6:57 am
by N1gel
If its for working with a database you could try looking at

mysql_escape_string()

http://uk.php.net/manual/en/function.my ... string.php

or

addslashes()

http://uk.php.net/manual/en/function.addslashes.php

Posted: Fri Oct 05, 2007 9:49 am
by Michael A
Re: mysql_escape_string()

This function is deprecated, do not use this function.

Instead, use mysql_real_escape_string().

It will help prevent malicious code from being injected into your database!

Posted: Fri Oct 05, 2007 10:56 am
by feyd
Also, don't use addslashes()... it has security holes in various older (maybe even current) versions of PHP.