Foros del Web » Programando para Internet » PHP »

Error insert ayuda

Estas en el tema de Error insert ayuda en el foro de PHP en Foros del Web. miren me sale este error: Código: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for ...
  #1 (permalink)  
Antiguo 20/10/2008, 20:32
 
Fecha de Ingreso: diciembre-2007
Mensajes: 927
Antigüedad: 16 años, 4 meses
Puntos: 12
Error insert ayuda

miren me sale este error:

Código:
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 'desc, categoria) VALUES (prueba, '

aqui esta el code completo aver que error encuentrann :P

Código PHP:
<?
include("../conectar.php");
include(
"funciones.php"); 

if(isset(
$_POST['titulo']) and isset($_POST['desc']) and isset($_POST['link']) and isset($_POST['foto']) and isset($_POST['cate'])) {
if(
$_POST['cate'] == 0) {
$titulo $_POST['titulo'];
$cate =  $_POST['cate'];
$desc =  $_POST['desc'];
$link =  $_POST['link'];
$foto =  $_POST['foto'];

$sql "INSERT INTO peliculas (titulo, link, foto, desc, categoria) VALUES ('$titulo', '$link', '$foto', '$desc', '$cate')";
mysql_query($sql) or die (mysql_error());
?>
<script language="javascript">
alert("Se la pelicula, Existosamente");
location.href = "index2.php?pag=peli";
</script>
<?
}else{
?>
<script language="javascript">
alert("No has elejido niguna categoria");
history.back();
</script>
<?
}
}else{
?>
<script language="javascript">
alert("ERROR!!!");
location.href = "index.php";
</script>
<?
}
?>
  #2 (permalink)  
Antiguo 20/10/2008, 20:36
Avatar de RollerSky  
Fecha de Ingreso: marzo-2008
Mensajes: 123
Antigüedad: 16 años
Puntos: 8
Respuesta: Error insert ayuda

categoria es un campo INTEGER? si es asi insertalo sin las comillas

Código PHP:
$sql "INSERT INTO peliculas (titulo, link, foto, desc, categoria) VALUES ('$titulo', '$link', '$foto', '$desc', $cate)"

salu2!
  #3 (permalink)  
Antiguo 20/10/2008, 21:08
 
Fecha de Ingreso: diciembre-2007
Mensajes: 927
Antigüedad: 16 años, 4 meses
Puntos: 12
Respuesta: Error insert ayuda

mm no categoria es un value con letras :P
  #4 (permalink)  
Antiguo 20/10/2008, 22:05
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Error insert ayuda

El problema es que tienes un campo llamado "desc", esa es una palabra reservada de SQL cuando haces un Order BY, tienes que ponerlo entre comillas invertidas para tomarlo: `desc`.

Saludos.
  #5 (permalink)  
Antiguo 21/10/2008, 07:47
 
Fecha de Ingreso: diciembre-2007
Mensajes: 927
Antigüedad: 16 años, 4 meses
Puntos: 12
Respuesta: Error insert ayuda

Gracias men no me habia percatado thnks!!!
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 04:48.