0
What good is GetSQLValueString
? And if there is a difference to PHP7, what difference does that function make? What happens if I don’t use it? Can anyone help me understand it better?
if (!function_exists("GetSQLValueString"))
{
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
After that, there is a section that uses this function.
if($cod_u > 0){
$updateSQL = sprintf("UPDATE usuario SET cod_id=%s, nome=%s, sexo=%s WHERE cod_u=%s",
GetSQLValueString( utf8_decode($_POST['cod_id']), "int"),
read: https://stackoverflow.com/questions/4458180/php-getsqlvaluestring-function
– novic