note 59382 deleted from function.set-magic-quotes-runtime by nlopess
| From: | nlopess@php.net | Date: | Fri, 16 Dec 2005 17:02:41 +0000 |
| Subject: | note 59382 deleted from function.set-magic-quotes-runtime by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100314@lists.php.net to get a copy of this message | ||
Note Submitter: e-5 at webhostingjournal dot net
----
magic_quotes_runtime is pretty much useless most of the time and is a good practice to turn it OFF
in your scripts when is not needed, this because you might lose some time dealing with errors until
you realize this feature is ON in your server.
magic_quotes_runtime is useful mostly when moving data from text files to databases or viceversa,
this is needed because storing unescaped strings in a database will cause all kinds of trouble as
soon as you store something containing an apostrophe or other special character, and can also leave
you open to SQL injection security vulnerabilities.
You can achieve similar functionality by using addslashes() with variables which content is gathered
from external sources. Also, you can manually clean up unescaped strings with magic_quotes_runtime
in your script you can use the stripslashes() function.
For example, the next snippet will clean up an array of strings (maybe from DB) unescaped with
addslashes() or magic_quotes_runtime:
<?PHP
if(!empty($db_array)){
foreach($_db_array as $i => $v){
$db_array[$i] = stripslashes($v);
}
}
?>
----
Mel
http://www.webhostingjournal.net/