miligraf Posted April 30, 2006 Share Posted April 30, 2006 When i want to edit some rows from a PHP file named [b]edit.php[/b] i get this message:[b]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 ''http://www.mydomain.com/images/50x50.gif', 'En este tutorial..[/b]Those fields are the Image (varchar(255), not null) and Description (text, not null) at the table. Quote Link to comment Share on other sites More sharing options...
freshrod Posted May 1, 2006 Share Posted May 1, 2006 If you could post exactly what those lines in the MySQL table say, or the PHP code where the query is, I might be able to help you better. Quote Link to comment Share on other sites More sharing options...
miligraf Posted May 1, 2006 Author Share Posted May 1, 2006 heres the php:[code]<link rel="stylesheet" type="text/css" href="../../css.css" /><?phpinclude ("../conbd.php");if (!isset($_POST['submit'])){ if ((!isset($_GET['id']) || trim($_GET['id']) == '')) { die ('Missing record ID!'); } $id = $_GET['id']; $query = "SELECT * FROM tutoriales WHERE id = '$id' "; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_row($result); $id = $row[0]; $titulo = $row[1]; $imagen = $row[2]; $descripcion = $row[4]; $enlace = $row[5]; $autor = $row[6]; ?> <span class='style20 Estilo3'> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <h2>Editar Tutorial #<?php echo $id; ?></h2> <table width="75%" border="0"> <tr class="Estilo3"> <th scope="col"><div align="left"><strong> <input type="hidden" name="id" value="<?php echo $id; ?>"> Titulo</strong></div></th> <th scope="col"><div align="right"> <input value="<?php echo stripslashes($titulo); ?>" name="titulo" type="text" size="100"> </div></th> </tr> <tr class="Estilo3"> <td><div align="left"><strong>Imagen</strong></div></td> <td><div align="right"> <input value="<?php echo stripslashes($imagen); ?>" name="imagen" type="text" size="100"> </div></td> </tr> <tr class="Estilo3"> <td><div align="left"><strong>Descripcion</strong></div></td> <td><div align="right"> <textarea name="descripcion" cols="75" rows="5"><?php echo stripslashes($descripcion); ?></textarea> </div></td> </tr> <tr class="Estilo3"> <td><div align="left"><strong>Enlace</strong></div></td> <td><div align="right"> <input name="enlace" type="text" value="<?php echo stripslashes($enlace); ?>" size="100"> </div></td> </tr> <tr class="Estilo3"> <td><div align="left"><strong>Autor</strong></div></td> <td><div align="right"> <input value="<?php echo stripslashes($autor); ?>" name="autor" type="text" size="100"> </div></td> </tr> </table> <h2> <input name="submit" type="Submit" value="Cambiar"> <input type="reset" value="Cancelar"> </h2> </form> </span> <?php } else { echo 'Tutorial no encontrado!'; }}else{$query = "UPDATE tutoriales SET name = '".mysql_real_escape_string($titulo)."', '".mysql_real_escape_string($imagen)."', '".mysql_real_escape_string($descripcion)."', '".mysql_real_escape_string($enlace)."', '".mysql_real_escape_string($autor)."', WHERE id = '$id' ";$result = mysql_query($query)or die(mysql_error());echo 'Tutorial editado exitosamente, <a href="index.php">regresar</a>.';}mysql_close($connection);?>[/code] Quote Link to comment Share on other sites More sharing options...
Brandon Jaeger Posted May 1, 2006 Share Posted May 1, 2006 You're not telling it what to set. You only did with "name".[code]$query = "UPDATE tutoriales SET name = '".mysql_real_escape_string($titulo)."', something1 = '".mysql_real_escape_string($imagen)."', something2 = '".mysql_real_escape_string($descripcion)."', something3 = '".mysql_real_escape_string($enlace)."', something4 = '".mysql_real_escape_string($autor)."', WHERE id = '$id' ";[/code] Quote Link to comment Share on other sites More sharing options...
miligraf Posted May 1, 2006 Author Share Posted May 1, 2006 Thx! but now i get this message:[b]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 id = '17'' at line 1[/b]:S Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 1, 2006 Share Posted May 1, 2006 Remove the comma before the "WHERE"Ken Quote Link to comment Share on other sites More sharing options...
miligraf Posted May 1, 2006 Author Share Posted May 1, 2006 Right now i changed it to this:[code]$query = "UPDATE tutoriales SET name = titulo = '".mysql_real_escape_string($titulo)."', imagen = '".mysql_real_escape_string($imagen)."', descripcion = '".mysql_real_escape_string($descripcion)."', enlace = '".mysql_real_escape_string($enlace)."', autor = '".mysql_real_escape_string($autor)."' WHERE id = '$id' ";[/code]But i get this: [b]Unknown column 'name' in 'field list'[/b] Quote Link to comment Share on other sites More sharing options...
miligraf Posted May 2, 2006 Author Share Posted May 2, 2006 *bump* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.