Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/12/2008, 06:01
Avatar de Pedro_valencia
Pedro_valencia
 
Fecha de Ingreso: diciembre-2007
Ubicación: Valencia
Mensajes: 82
Antigüedad: 16 años, 4 meses
Puntos: 6
Respuesta: ¿Es seguro con esta función?

Uso mysql.

Y, ¿htmlentities no convierte todos los carácteres a entidades HTML?

Yo solo quiero convertir los carácteres especiales.

¿La mejorariais? ¿Alguna sugerencia? ¿Alguna función mejor?

¿Qué os parece esta que he encontrado?

Código PHP:

if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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;
}


Un saludo.