Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/05/2004, 16:20
famp
 
Fecha de Ingreso: marzo-2004
Mensajes: 271
Antigüedad: 20 años, 1 mes
Puntos: 0
no me va scrip editor

Este codigo me genra 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 'WHERE idcomunidad =' at line 1

Joe me compro un libro para no meletar y al final acabo jodiendo por fa una ayuda.

los includes funcionan por que otros scrip trabaja con los includes.
<html>

<head>
<title>editor de comunidades</title>
</head>

<body>

<?php
include ("includes/config.php");
include ("includes/funciones.php");

//si la forma ha sido enviada editamos el registro.
if(isset($_POST['submit'])){
//nos conectamos a mysql
$cnx = conectar ();

$sql = "UPDATE directorio SET ";
$sql .= "nombre ='".$_POST['nombre']."',";
$sql .= " WHERE idcomunidad =".$_POST['idcomunidad'];
$res = mysql_query($sql) or die(mysql_error());
echo "Registro actualizado.<br><a href='listado.php'>regresar</a>";
mysql_close($cnx);
exit;
}

//si no hay idcomunidad, no puede seguir.
if(empty($_GET['idcomunidad'])){
header("Location: comunidades.php");
exit;
}

//nos conectamos a mysql
$cnx = conectar ();

//consulta para mostrar los datos.
$sql = "SELECT * FROM comunidades WHERE idcomunidad=".$_GET['idcomunidad'];
$res= mysql_query($sql) or die (mysql_error());

if( mysql_num_rows($res) >0){
//si hay resultados hacemos la forma.
?>
<form name="form1" method="post" action="<?echo $_SERVER['PHP_SELF'];?>">
<table width="400" border="1" cellpadding="0" cellspacing="0">
<?
//impresión de los datos.
while ($fila = mysql_fetch_array($res)) {
?>
<tr>
<td>nombre</td>
<td><input name="nombre" type="text" id="nombre" value="<? echo $fila['nombrecomunidad'];?>"></td>
</tr>

<tr>
<td>&nbsp;</td>
<td align="right"><input type="submit" name="submit" value="enviar"></td>
</tr>
</table>
</form>
<?
}
}else{
//no hay resultados, id malo o no existe.
echo "no se obtuvieron resultados";
}
mysql_close($cnx);
?>

</body>

</html>