Estou com um problema e não sei como resolver, uso essa função para validar o recebimento de algumas variáveis:
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;
}
}
As variáveis estão sendo tratadas assim:
$IdCategoria = GetSQLValueString($_POST['IdCategoria'],"int");
$IdUnicoop = GetSQLValueString($_POST['IdUnicoop'], "int");
$Palavra = GetSQLValueString('%'.$_POST['Palavra'].'%',"text");
Gostaria de fazer o tratamento para algumas datas que tenho, elas estão sendo recebidas assim:
$DtInicial = $_POST['DtInicial'];
$DtFinal = $_POST['DtFinal'];
$DtInicial = GetSQLValueString($DtInicial, 'date');
?