Foros del Web » Programando para Internet » PHP »

Problema básico sintaxis MySQL

Estas en el tema de Problema básico sintaxis MySQL en el foro de PHP en Foros del Web. Estoy haciendo unas pruebas con unas tablas muy sencillas (datos basicos de un album de musica), y me he encontrado con un error de sintaxis ...
  #1 (permalink)  
Antiguo 04/01/2012, 20:00
 
Fecha de Ingreso: diciembre-2010
Ubicación: Asturias
Mensajes: 5
Antigüedad: 13 años, 4 meses
Puntos: 0
Problema básico sintaxis MySQL

Estoy haciendo unas pruebas con unas tablas muy sencillas (datos basicos de un album de musica), y me he encontrado con un error de sintaxis que no veo.
El error dice:
Cita:
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 'release, tracks, length) VALUES ('Gaia', 1, 1, '2003-09-08', 12, '72:75')' at line 1
Y la query es:
Cita:
INSERT INTO music_album (title, type, artist, release, tracks, length) VALUES ('Gaia', 1, 1, '2003-09-08', 12, '72:75')
¿Veis cuál puede ser el error? Porque no lo entiendo.

Gracias de antemano.
  #2 (permalink)  
Antiguo 04/01/2012, 20:02
Avatar de ZoroRoronoa  
Fecha de Ingreso: marzo-2011
Ubicación: California, USA
Mensajes: 824
Antigüedad: 13 años, 1 mes
Puntos: 116
Respuesta: Problema básico sintaxis MySQL

a los numeros 1, 1, y 12, que no estan encomillados, agregale comillas simples

'1', '1', .... , '12' ...

Saludos.
__________________
Programador jQuery & PHP
  #3 (permalink)  
Antiguo 04/01/2012, 20:04
 
Fecha de Ingreso: diciembre-2010
Ubicación: Asturias
Mensajes: 5
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Problema básico sintaxis MySQL

Nop, no me ha funcionado, sigue ocurriendo lo mismo:
Cita:
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 'release, tracks, length) VALUES ('Gaia', '1', '1', '2003-09-08', '12', '72:75')' at line 1
  #4 (permalink)  
Antiguo 04/01/2012, 20:10
Avatar de andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Problema básico sintaxis MySQL

release si no estoy mal es una palabra reservada de MySQL prueba así:

Código SQL:
Ver original
  1. INSERT INTO music_album (title, TYPE, artist, `release`, tracks, LENGTH) VALUES ('Gaia', 1, 1, '2003-09-08', 12, '72:75')
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP
  #5 (permalink)  
Antiguo 04/01/2012, 20:14
 
Fecha de Ingreso: diciembre-2010
Ubicación: Asturias
Mensajes: 5
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Problema básico sintaxis MySQL

Ok, eso sí me ha funcionado. No se me había pasado por la cabeza que fuese palabra reservada (aunque es bastante obvio :P).

Muchas gracias!

Etiquetas: mysql, sintaxis, sql, tabla
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 23:37.