note 83503 modified in function.mysql-real-escape-string by felipe

From: Date: Thu, 29 May 2008 10:55:22 +0000
Subject: note 83503 modified in function.mysql-real-escape-string by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139971@lists.php.net to get a copy of this message
<?php function mysql_prep($value){ $magic_quotes_active = get_magic_quotes_gpc(); $new_enough_php = function_exists("mysql_real_escape_string"); // i.e PHP >= v4.3.0 if($new_enough_php){ //undo any magic quote effects so mysql_real_escape_string can do the work if($magic_quotes_active){ $value = stripslashes($value); } $value = mysql_real_escape_string($value); }else{ // before PHP v4.3.0 // if magic quotes aren't already on this add slashes manually if(!$magic_quotes_active){ $value = addslashes($value); } //if magic quotes are avtive, then the slashes already exist } return $value; } ?> --was-- function mysql_prep($value){ $magic_quotes_active = get_magic_quotes_gpc(); $new_enough_php = function_exists("mysql_real_escape_string"); // i.e PHP >= v4.3.0 if($new_enough_php){ //undo any magic quote effects so mysql_real_escape_string can do the work if($magic_quotes_active){ $value = stripslashes($value); } $value = mysql_real_escape_string($value); }else{ // before PHP v4.3.0 // if magic quotes aren't already on this add slashes manually if(!$magic_quotes_active){ $value = addslashes($value); } //if magic quotes are avtive, then the slashes already exist } return $value; } http://php.net/manual/en/function.mysql-real-escape-string.php

« previous php.notes (#139971) next »