note 57894 deleted from function.mysql-real-escape-string by aidan
| From: | aidan@php.net | Date: | Sat, 04 Feb 2006 12:06:13 +0000 |
| Subject: | note 57894 deleted from function.mysql-real-escape-string by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102982@lists.php.net to get a copy of this message | ||
Note Submitter: cedric at over minus blog dot com
----
I prefer this one as is_numeric will tell 0123 is an integer and mysql will move that to 123 even if
it is a varchar field.
<?
function anti_inject ($value,$txt=false) {
if (get_magic_quotes_gpc()) $value=stripslashes($value);
if (!is_numeric($value))
$value="'".mysql_real_escape_string($value)."'";
if ($txt && is_numeric($value)) $value="'".$value."'";
return $value;
}
?>
Add: perhaps you will need (like me, but not shown here) to use a specific Link identifier to mysql