Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/11/2007, 09:45
Rafa2004
 
Fecha de Ingreso: noviembre-2004
Ubicación: Caracas-Venezuela
Mensajes: 30
Antigüedad: 19 años, 5 meses
Puntos: 0
Información Problema al Insertar Nuevo Registro

Hola tengo el siguiente codigo en php pero al ejecutarlo me dal 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 ')' at line 1"

Que debo corregir? donde esta el error?

El codigo es el siguiente:

<?php
//si la forma ha sido enviada editamos el registro.
if(isset($_POST['submit'])){

include ("includes/config.php");
include ("includes/funciones.php");
//nos conectamos a mysql
$cnx = conectar ();

$campos = "nombre,apellido,dni,ciudad,email,telfijo,telmovil ,agente,fechaing,publicidad";
$valores .= "'".$_POST['nombre']."',";
$valores .= "'".$_POST['apellido']."',";
$valores .= "'".$_POST['dni']."',";
$valores .= "'".$_POST['ciudad']."',";
$valores .= "'".$_POST['email']."',";
$valores .= "'".$_POST['telfijo']."',";
$valores .= "'".$_POST['telmovil']."',";
$valores .= "'".$_POST['agente']."'";
$valores .= "'".$_POST['fechaing']."',";
$valores .= "'".$_POST['publicidad']."',";
$sql = "INSERT INTO directorio ($campos) VALUES($valores)";
$res = mysql_query($sql) or die(mysql_error());
echo "Registro ingresado.<br><a href='listado.php'>regresar</a>";
mysql_close($cnx);
exit;
}
?>
<form name="form1" method="post" action="<?echo $_SERVER['PHP_SELF'];?>">
<table width="400" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>nombre</td>
<td><input name="nombre" type="text" id="nombre" value=""></td>
</tr>
<tr>
<td>apellido</td>
<td><input name="apellido" type="text" id="apellido" value=""></td>
</tr>
<tr>
<td>dni</td>
<td><input name="dni" type="text" id="dni" value=""></td>
</tr>
<tr>
<td>ciudad</td>
<td><input name="ciudad" type="text" id="ciudad" value=""></td>
</tr>
<tr>
<td>email</td>
<td><input name="email" type="text" id="email" value=""></td>
</tr>
<tr>
<td>Telf Fijo</td>
<td><input name="telfijo" type="text" id="telfijo" value=""></td>
</tr>
<tr>
<td>Telf Móvil</td>
<td><input name="telmovil" type="text" id="telmovil" value=""></td>
</tr>
<tr>
<td>Agente</td>
<td><input name="agente" type="text" id="agente" value=""></td>
</tr>
<tr>
<td>Fecha de Ingreso</td>
<td><input name="fechaing" type="Date" id="fechaing" value=""></td>
</tr>
<tr>
<td>Publicidad</td>
<td><input name="publicidad" type="text" id="publicidad" value=""></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="right"><input type="submit" name="submit" value="enviar"></td>
</tr>
</table>
</form>

Gracias