Foros del Web » Programando para Internet » PHP »

error You have an error in your SQL syntax; check the manual that corresponds to your

Estas en el tema de error You have an error in your SQL syntax; check the manual that corresponds to your en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 07/11/2009, 08:08
 
Fecha de Ingreso: abril-2009
Mensajes: 173
Antigüedad: 15 años
Puntos: 0
error You have an error in your SQL syntax; check the manual that corresponds to your

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 '-CIF, TIPO-PERSONA, NOMBRE, APELLIDOS, DIRECCION, COD-POSTAL, LOCALIDAD, PROVINC' at line 1



que puede ser? quiero insertar registros desde un formulario.
Gracias
  #2 (permalink)  
Antiguo 07/11/2009, 08:17
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Hola

Muestranos la consulta. Que yo sepa por aquí no andan adivinos

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #3 (permalink)  
Antiguo 07/11/2009, 08:17
Avatar de Vun
Vun
Colaborador
 
Fecha de Ingreso: agosto-2009
Ubicación: Benalmádena, España
Mensajes: 2.265
Antigüedad: 14 años, 8 meses
Puntos: 150
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Escribe la linea entera, el mysql_query(...........

Y si puedes la estructura de las tablas con afecte dicho query, con eso te lo solucionan rapido
  #4 (permalink)  
Antiguo 07/11/2009, 08:25
 
Fecha de Ingreso: abril-2009
Mensajes: 173
Antigüedad: 15 años
Puntos: 0
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

mysql_select_db($database_censo, $censo);
$query_propietarios = "SELECT * FROM propietarios";
$propietarios = mysql_query($query_propietarios, $censo) or die(mysql_error());
$row_propietarios = mysql_fetch_assoc($propietarios);
$totalRows_propietarios = mysql_num_rows($propietarios);

mysql_select_db($database_censo, $censo);
$query_tipopersona = "SELECT * FROM `tipo-persona`";
$tipopersona = mysql_query($query_tipopersona, $censo) or die(mysql_error());
$row_tipopersona = mysql_fetch_assoc($tipopersona);
$totalRows_tipopersona = mysql_num_rows($tipopersona);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO propietarios (DNI-CIF, TIPO-PERSONA, NOMBRE, APELLIDOS, DIRECCION, COD-POSTAL, LOCALIDAD, PROVINCIA, PAIS, TELEF-FIJO, TELEF-MOVIL, MAIL, FAX, OBSERVACIONES) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['DNICIF'], "text"),
GetSQLValueString($_POST['TIPOPERSONA'], "text"),
GetSQLValueString($_POST['NOMBRE'], "text"),
GetSQLValueString($_POST['APELLIDOS'], "text"),
GetSQLValueString($_POST['DIRECCION'], "text"),
GetSQLValueString($_POST['CODPOSTAL'], "text"),
GetSQLValueString($_POST['LOCALIDAD'], "text"),
GetSQLValueString($_POST['PROVINCIA'], "text"),
GetSQLValueString($_POST['PAIS'], "text"),
GetSQLValueString($_POST['TELEFFIJO'], "text"),
GetSQLValueString($_POST['TELEFMOVIL'], "text"),
GetSQLValueString($_POST['MAIL'], "text"),
GetSQLValueString($_POST['FAX'], "text"),
GetSQLValueString($_POST['OBSERVACIONES'], "text"));

mysql_select_db($database_censo, $censo);
  #5 (permalink)  
Antiguo 07/11/2009, 08:49
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Hola

Usa guión bajo (_). DNI_CIF, TIPO_PERSONA

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #6 (permalink)  
Antiguo 07/11/2009, 09:02
 
Fecha de Ingreso: abril-2009
Mensajes: 173
Antigüedad: 15 años
Puntos: 0
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

ahora me salen estos
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 '-POSTAL, LOCALIDAD, PROVINCIA, PAIS, TELEF_FIJO, TELEF_MOVIL, MAIL, FAX, OBSERVA' at line 1
  #7 (permalink)  
Antiguo 07/11/2009, 09:06
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Hola

COD_POSTAL

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #8 (permalink)  
Antiguo 07/11/2009, 09:34
 
Fecha de Ingreso: abril-2009
Mensajes: 173
Antigüedad: 15 años
Puntos: 0
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Si hago eso de los _ guiones ahora me da esto:
Unknown column 'DNI_CIF' in 'field list'

No sera mejor cambiar los datos de la tabla y dejarlos sin guiones?
  #9 (permalink)  
Antiguo 07/11/2009, 09:50
Avatar de Vun
Vun
Colaborador
 
Fecha de Ingreso: agosto-2009
Ubicación: Benalmádena, España
Mensajes: 2.265
Antigüedad: 14 años, 8 meses
Puntos: 150
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Claro , tienes que cambiar ahora los nombres de los campos tambien para que concuerde con tu codigo
  #10 (permalink)  
Antiguo 07/11/2009, 09:54
 
Fecha de Ingreso: abril-2009
Mensajes: 173
Antigüedad: 15 años
Puntos: 0
Respuesta: error You have an error in your SQL syntax; check the manual that correspo

Para alinear formulario?
por ejemplo
en la izquierda NOMBRE:SUCAJATEXTO Y AQUI AL LADO APELLIDO:SUCAJATEXO .
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 13:41.