Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/01/2005, 01:11
kez0
 
Fecha de Ingreso: enero-2004
Mensajes: 431
Antigüedad: 20 años, 3 meses
Puntos: 6
...error in your SQL syntax... :'(

Al ejecutar un script que inserta unos datos a la DB me sale este 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 'desc,tel,ext1,usuario) VALUES ('NISSAN','Altima','1456','44444'

el codigo del formulario es este
Código HTML:
<FORM method="post" action="publicar.php" enctype="multipart/form-data">
Marca<input type="text" name="marca"><br>Modelo:<input type="text" name="modelo"><br>Año<input type="text" name="ano"><br>Precio<input type="text" name="precio"><br>Moneda:<input type="text" name="moneda">Desc.<textarea name="desc"></textarea><br><input type="text" name="tel"><br>imagen:<input type="file" name="img1" size="20"><br><input type="submit" value="publicar"> 
y el archivo publicar.php es este:
Código PHP:
<?
include("ident.php");//este komprueba ke esten registrados y logueados
if($loginCorrecto) {
include(
"conex.php");//konexion kon MYSQL
include("inc/func.inc");//ALGUNAS FUNCIONES DE SEGURIDAD COMO quitar()
$ext=$_FILES['img1']['type'];  
$img_temp=$_FILES['img1']['tmp_name']; 
$img1 addslashes(fread(fopen($img_temp"rb"), filesize($img_temp))); 
if(
$ext == "image/pjpeg") {
    
$ext1 "jpg";

if(
$ext == "image/gif") {
    
$ext1="gif";

if(
$ext1 == "") {
    
?>
<SCRIPT LANGUAGE="JavaScript">
<!--
alert('El formato de la imagen no es correcto asegurese de que sea JPG o GIF');
history.go(-1);
//-->
</SCRIPT>
<?
        
exit;
    } 
$sql "INSERT INTO anuncios (marca,modelo,ano,precio,moneda,img1,desc,tel,ext1,usuario) VALUES ('".quitar($_POST["marca"])."','".quitar($_POST["modelo"])."','".quitar($_POST["ano"])."','".quitar($_POST["precio"])."','".quitar($_POST["moneda"])."',".$img1.",'".quitar($_POST["desc"])."','".quitar($_POST["tel"])."','".$ext1."','".$_COOKIE["ususuario"]."')"
mysql_query($sql) or die(mysql_error());

?>
<SCRIPT LANGUAGE="JavaScript">
<!--
alert('Su anuncio ha sido publicado exitosamente.\nLe deseamos buena suerte con su venta.\nNo olvide que al venderse su carro debera entrar a su cuenta y borrar el anuncio de lo contrario el anuncio permanecera ahi y sus datos estaran disponibles para todos.\n');
location.href="index.php";
//-->
</SCRIPT>
<?
} else { 
    
?>
        <p align="center"><b><font face="Verdana" size="1">Esta area es solo para 
usuarios registrados.</font></b></p><center><form method="post" action="ingresar.php">
<table border="0" width="346" height="79">
    <tr>
        <td height="23" width="95" align="right"><font face="Verdana" size="1">
        Usuario:</font></td>
        <td height="23" width="240"><input type="text" name="usuario" size="20" class="txt"></td>
    </tr>
    <tr>
        <td height="23" width="95" align="right"><font face="Verdana" size="1">
        Contraseña:</font></td>
        <td height="23" width="240">
        <input type="password" name="password" size="20" class="txt"></td>
    </tr>
    <tr>
        <td height="23" width="96">&nbsp;</td>
        <td height="23" width="240">
        <input type="submit" value="Login" name="submit" class="boton"></td>
    </tr>
</table>
<p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1">
<a href="index.php?modo=recuperarpass">¿Contraseña perdida?</a></font></p>
<p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1">
<a href="index.php?modo=registro">Si no estas registrado haz click aqui para 
registrarte GRATUITAMENTE</a></font></p>
</form>
</center>
<?
}
    
?>
pero al tratar de publicar algo me tira el 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 'desc,tel,ext1,usuario) VALUES ('NISSAN','Altima','1456','44444'


Alguna idea??


Saludos
__________________
El que teme preguntar, se averguenza de aprender.

Última edición por kez0; 21/10/2007 a las 13:45