PHP & MySQL | Tutorials

David Carr

Magic Quotes

This tutorial will explain what magic quotes are and how to use them. When Magic Quotes are enabled will automatically escape single and double quotation marks.

This helps prevent problems in php/html.

There are two types of Magic Quotes:

magic_quotes_gpc which works for forms, urls and cookies (gpc stands for get, post and cookie).

magic_quotes_runtime which works for data from external files and databases.

If there is an apostrophe like: dave's then the result would be daves to get round this you can use the function stripslashes() This function removes any backslashes found.

$text = "this is dave's data";

if magic quotes are activated on the server then the result when printed would be:

this is daves data

To get round this use stripslashes()

$text stripslashes($text);
$text = "this is dave's data";

the result would then be:

this is dave's data

A doubles backslash will be turned into a single backslash using the stripslashes() function 

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.