how to avoide the special characters in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
qumar
Forum Commoner
Posts: 29
Joined: Wed Nov 01, 2006 8:20 am

how to avoide the special characters in php

Post 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.
User avatar
N1gel
Forum Commoner
Posts: 95
Joined: Sun Apr 30, 2006 12:01 pm

Post 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
Michael A
Forum Newbie
Posts: 17
Joined: Wed Oct 03, 2007 9:25 am

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Also, don't use addslashes()... it has security holes in various older (maybe even current) versions of PHP.
Post Reply