Estoy modificando mi web y ahora mismo me he atascado con un fallo.
He creado un formulario que recupera datos de una base de datos para poder editarlos y guardar los cambios. Todo va bien hasta el paso de pulsar el boton de guardar cambios ya que me da 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 'where linkID = '2'' at line 7
El código de la página es el siguiente:
Código:
Mi nivel de php y sql es básico por lo que les agradecería alguna sugerencia de por donde tirar pues me encuentro atascado con este tema.<? require_once("../conn.php"); require_once("access.php"); if(isset($_POST[s1])) { $MylinkID = trim($_POST[linkID]); $MylinkNOMBRE = trim($_POST[linkNOMBRE]); $MylinkDESCRIPCION = trim($_POST[linkDESCRIPCION]); $MylinkURL = trim($_POST[linkURL]); $q1 = "update class_links set linkID = '$MylinkID', linkNOMBRE = '$MylinkNOMBRE', linkDESCRIPCION = '$MylinkDESCRIPCION', linkURL = '$MylinkURL', where linkID = '$_GET[id]' "; mysql_query($q1) or die(mysql_error()); header("location:linksadmin.php"); exit(); } require_once("AdminNavigation.php"); //get the links info $q1 = "select * from class_links where linkID = '$_GET[id]' "; $r1 = mysql_query($q1) or die(mysql_error()); $a1 = mysql_fetch_array($r1); ?> <br> <form method=post> <table align=center width=400> <tr> <td align=right>Id:</td> <td align=right> <p align="left"> <input name=linkID size=35 maxlength=5 value="<?=$a1[linkID]?>" style="float: left"></td> </tr> <tr> <td align=right>Nombre:</td> <td align=right> <input name=linkNOMBRE size=35 maxlength=70 value="<?=$a1[linkNOMBRE]?>" style="float: left"></td> </tr> <tr> <td align=right>Descripción:</td> <td align=right> <p align="left"> <textarea name=linkDESCRIPCION rows=4 cols=34 style="float: left"><?=$a1[linkDESCRIPCION]?></textarea></td> </tr> <tr> <td align=right>Dirección Web:</td> <td align=right> <input name=linkURL size=35 maxlength=70 value="<?=$a1[linkURL]?>" style="float: left"></td> </tr> <tr> <td align=right> </td> <td align=right> </td> </tr> <tr> <td align=right> </td> <td align=right> <input type=submit name=s1 value="Guardar Cambios" class="sub1" style="float: left"></td> </tr> </table> </form> <br><br> <? require_once("admin_footer.php"); ?>
saludos y gracias anticipadas.