note 62921 deleted from function.mysql-real-escape-string by danbrown
| From: | danbrown@php.net | Date: | Sat, 14 Mar 2009 15:10:17 +0000 |
| Subject: | note 62921 deleted from function.mysql-real-escape-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151938@lists.php.net to get a copy of this message | ||
Note Submitter: php at iain dot nl
----
It's quite easy to stop the problem of 0666 returning as 666 in the example of quote_smart.
Look at this:
<?php
// Quote variable to make safe
function quote_smart($value) {
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value) || $value[0] == '0') {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
?>
It now checks if there is a leading zero, and then it should be treated als a text, instead as a
numerical value. Just an easy workaround.