Okay,
I’m going to risk verbal lashings, and go ahead and ask the following question. I have a problem with over-analyzing sometimes, and my brain hurts.
get_magic_quotes_gpc()
I understand that this was created for ease-of-use for safe db entry. I also understand that it escapes certain characters (quotes and such) in order to not affect the SQL syntax.
stripslashes
I understand that this undoes what get_magic_quotes_gpc() may impose upon a $_POST value.
mysql_real_escape_string
Is this like “the real slim shady”, where once you’ve added a “function strip_quotes()”, you can then safely control what you enter into a db?
Would it, therefore, be safe to assume that this is correct:
[php]
//set up function to standby if quotes is on
function noQuotes() {
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map(‘stripslashes_deep’, $value) : stripslashes($value);
return $value;
}
$_POST = array_map(‘stripslashes_deep’, $_POST);
$_GET = array_map(‘stripslashes_deep’, $_GET);
$_COOKIE = array_map(‘stripslashes_deep’, $_COOKIE);
}
}
//normalize all input if magic_quotes is on
if (function_exists(‘noQuotes’)) {
noQuotes();
}
//when the time comes, add slashes where necessary
$name = mysql_real_escape_string($_POST[‘name’]);
$email = mysql_real_escape_string($_POST[‘email’]);
[/php]
So, my question is, is the above a safe assumption? Or am I missing something? My understanding is that strip_slashes corrects a universal blip, and that mysql_real_escape is a self-controlled version…