Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

[SOLUCIONADO] Problema con Query en PHP

Estas en el tema de Problema con Query en PHP en el foro de Mysql en Foros del Web. Hola tengo un problema con la siguiente sentencia: Código PHP: $updateSQL  =  sprintf ( "UPDATE Usuarios SET Nombre=%s, NIP=%s, E_mail=%s, Extension=%s WHERE Ficha= %s" ,                         GetSQLValueString ( $_POST [ 'Nombre' ],  "undefined" ), ...
  #1 (permalink)  
Antiguo 07/05/2012, 02:33
 
Fecha de Ingreso: mayo-2012
Ubicación: df
Mensajes: 12
Antigüedad: 11 años, 11 meses
Puntos: 0
Exclamación Problema con Query en PHP

Hola tengo un problema con la siguiente sentencia:

Código PHP:
$updateSQL sprintf("UPDATE Usuarios SET Nombre=%s, NIP=%s, E_mail=%s, Extension=%s WHERE Ficha= %s",
                       
GetSQLValueString($_POST['Nombre'], "undefined"),
                       
GetSQLValueString($_POST['NIP'], "text"),
                       
GetSQLValueString($_POST['E_mail'], "text"),
                       
GetSQLValueString($_POST['Extension'], "text"),
                       
GetSQLValueString(trim($_POST['Ficha']),"int"));

  
mysql_select_db($database_Pases2$Pases2);
  
$Result1 mysql_query($updateSQL$Pases2) or die(mysql_error()); 
que arroja el siguiente error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' NIP='1234, E_mail='1234, Extension='1234 WHERE Ficha= 1234' at line 1

Ese ' APOSTROFE que esta en rojo despues de Ficha = 1234 es el error pero no se en qeu momento lo pone. alguien que me pueda ayudar y de antemano gracias.

Los valores estan bien definidos pero adjunto el codigo para mayor referencia:
Código PHP:
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
  #2 (permalink)  
Antiguo 07/05/2012, 03:42
Avatar de DooBie  
Fecha de Ingreso: septiembre-2004
Mensajes: 1.101
Antigüedad: 19 años, 7 meses
Puntos: 71
Respuesta: Problema con Query en PHP

Yo cambiaria el undefined del nombre por text.
Esas cosas pasan cuando usas dreamweaver...
  #3 (permalink)  
Antiguo 07/05/2012, 03:48
 
Fecha de Ingreso: mayo-2012
Ubicación: df
Mensajes: 12
Antigüedad: 11 años, 11 meses
Puntos: 0
De acuerdo Respuesta: Problema con Query en PHP

Gracias

  #4 (permalink)  
Antiguo 07/05/2012, 04:27
Avatar de DooBie  
Fecha de Ingreso: septiembre-2004
Mensajes: 1.101
Antigüedad: 19 años, 7 meses
Puntos: 71
Respuesta: Problema con Query en PHP

Cita:
Iniciado por omar0989 Ver Mensaje
Gracias

Eso es que funciona?
  #5 (permalink)  
Antiguo 07/05/2012, 04:28
 
Fecha de Ingreso: mayo-2012
Ubicación: df
Mensajes: 12
Antigüedad: 11 años, 11 meses
Puntos: 0
Respuesta: Problema con Query en PHP

Si y bien hasta ahorita

Etiquetas: query
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:23.