note 62921 added to function.mysql-real-escape-string
| From: | php at iain dot nl | Date: | Sun, 12 Mar 2006 09:59:46 +0000 |
| Subject: | note 62921 added to function.mysql-real-escape-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105359@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 194.109.193.119
Probable Submitter: 82.134.132.149
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php
Edit -- http://master.php.net/note/edit/62921
Del: integrated -- http://master.php.net/note/delete/62921/integrated
Del: useless -- http://master.php.net/note/delete/62921/useless
Del: bad code -- http://master.php.net/note/delete/62921/bad+code
Del: spam -- http://master.php.net/note/delete/62921/spam
Del: non-english -- http://master.php.net/note/delete/62921/non-english
Del: in docs -- http://master.php.net/note/delete/62921/in+docs
Del: other reasons-- http://master.php.net/note/delete/62921
Reject -- http://master.php.net/note/reject/62921
Search -- http://master.php.net/manage/user-notes.php