Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/01/2004, 13:28
Pavement
 
Fecha de Ingreso: noviembre-2003
Ubicación: Barcelona
Mensajes: 31
Antigüedad: 20 años, 5 meses
Puntos: 0
error al eliminar

Hola.

Tengo el siguiente código que a partir de un combo box, selecciono la tabla, me lista los registros con checkboxs y al seleccionarlos me tendría que borrar los escogidos, pero me sale el siguiente error y no se porque, ya que el delete me parece estar bien hecho.

MySQL dice: 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 'WHERE Codi_client IN (1577)' at line 1

El código es el siguiente:

html>
<head>
<title>Volcado Tipus Articles</title>
</head>

<body bgcolor="#FFFFCC">

<?php include("connexio.php");?>


<?php


//arreglo de tablas
$tbls[1]="Clients";

//arreglos nombre de tablas para el combo box
$txt[1]="Clients";

//formulario y tabla?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" enctype="multipart/form-data">
<table name="formulario" width="770" border="1" align="center">
<tr>
<td>Eliminar Datos desde:</td>
<td> <?php $tablas= "<select name=\"tablas\">"; echo $tablas;?>
<?php for ($i = 0; $i <= 2; $i++){
echo "<option value=\"".$tbls[$i]."\">".$txt[$i]."</option>";
}?>
</select>&nbsp;<input type="Submit" name="Submit" value="Enviar"></td>
</tr>
</table></form>
<?php
//Query a la base de datos
if(isset($_POST['Submit']))
{
mysql_select_db("oldteddys");
$result = mysql_query("SELECT * FROM ".$_POST['tablas']."") or die("MySQL dice: ".mysql_error());
//SACAMOS A RELUCIR LAS TABLAS
echo $result;
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\" enctype=\"multipart/form-data\">
<table name=\"tabla\" width=\"770\" border=\"1\" align=\"center\">
<tr>
<td>Codi</td><td>Nom Client</td><td>Eliminar</td>";
while($row=mysql_fetch_array($result))
{
echo "<tr><td>".$row['Codi_client']."</td>
<td>".$row['Nom_client']."</td><td><input type=\"checkbox\" name=\"eliminar[]\" value=\"".$row['Codi_client']."\"></td>";
}
echo "</tr><tr><td colspan=\"3\" bgcolor=\"gray\" align=\"right\"><input type=\"Submit\" name=\"Borrar\" value=\"Borrar\"></tr></td>
</table></form>";
}
//ELIMINAMOS ID DE LA RESPECTIVA TABLA
if(isset($_POST['Borrar']))
{
$array =implode(',',$_POST['eliminar']);
mysql_select_db("oldteddys");
mysql_query("DELETE FROM ".$_POST['tablas']. "WHERE Codi_client IN (".$array.")",$Connexio) or die("MySQL dice: ".mysql_error());
}
?>
</body>
</html>

Agradeceria ayuda.

Muchas gracias