note 83450 deleted from function.mysql-real-escape-string by tularis
| From: | tularis@php.net | Date: | Tue, 27 May 2008 12:36:33 +0000 |
| Subject: | note 83450 deleted from function.mysql-real-escape-string by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-139851@lists.php.net to get a copy of this message | ||
Note Submitter: razonklnbd at hotmail dot com
----
really a handy function for sql injection. extra checking for magic quotes enabled or not. if it is
not enabled then add slashes.. also for real escape it will strip slash the value and do real
escaping...
/*
real escaping or addslashes after checking magic quotes enable or not...
for security measure of sql injection or sql hijeking..
created by : Md. Shahadat Hossain Khan Razon (razonklnbd@hotmail.com)
created date : 20080527
last modified date : 20080527
*/
function sqlSafeString($p_val, $p_real_escaping_enabled = true) {
if(true == $p_real_escaping_enabled) $f_val = mysql_real_escape_string((get_magic_quotes_gpc() ==
yes ? stripslashes($p_val) : $p_val));
else $f_val=(get_magic_quotes_gpc() == yes ? $p_val : addslashes($p_val));
return $f_val;
}