Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/09/2008, 12:55
Avatar de Ronruby
Ronruby
 
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 18 años, 3 meses
Puntos: 416
Respuesta: fallas y errores de php y mysql

mysql_real_escape_string
http://www.php.net/manual/es/functio...ape-string.php

Esa funcion evita las inyecciones SQL.
Tambien Dreamweaver tiene una funcion llamada GetSQLValueString.

Código PHP:
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; 
}