Magic Quotes

Magic Quotes

Escaping troublesome characters

When you are inserting data into a MySQL database, certain characters have a special meaning

and must therefore be escaped if you wish to insert these characters literally.

By default, PHP will escape these characters for you in any data coming from the user in GET,

Post or Cookie data. This magic escaping is known as Magic Quotes and can be configured in

your php.ini file by setting the magic_quotes_gpc directive.

The characters affected are \ ‘ ” and NUL (char 0). If these characters appear in user-supplied data

they will be escaped with a \ (backslash).

Some people prefer to turn this feature off and handle escaping data manually using the

addslashes() function. There is a converse function, stripslashes(), which removes the backslash

characters in an escaped string.

 

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.