Presto-X Posted November 3, 2008 Share Posted November 3, 2008 Hello guys, I have been working on this page most of the night and my eyes are killing me, can any one see what I'm missing here? Where using the INSERT INTO in works great but when it needs to use UPDATE it does not save the data to the database ??? if(isset($_POST['submit'])){ mysql_select_db($database_startpage, $startpage); $id = $_POST['id']; $icon = $_POST['icon']; $title = $_POST['title']; $url = $_POST['url']; $order = $_POST['order']; $target = $_POST['target']; if (empty($_POST['id'])){ $query = "INSERT INTO icons VALUES ('','$icon','$title','$url','$order','$target')"; }else{ $query = "UPDATE icons SET icon='$icon', title='$title', url='$url', order='$order', target='$target' WHERE id='$id'"; } mysql_query($query); echo '<h1>Icon Saved!</h1> <meta http-equiv="refresh" content="1;url=icons_edit_list.php" />'; } this is the top of my form <form action="icons_form.php<?PHP if (isset($_GET['id'])){echo '?id='.$_GET['id'];} ?>" method="POST"> <input type="hidden" name="id" value="<?PHP echo $_GET['id']; ?>" /> <input type="hidden" name="submit" value="1" /> Link to comment https://forums.phpfreaks.com/topic/131166-solved-update-query-not-updating-row/ Share on other sites More sharing options...
Adam Posted November 3, 2008 Share Posted November 3, 2008 try changing "mysql_query($query);" to: "mysql_query($query) or die(mysql_error());" .. should tell you of any errors.. This may not be a great concern right now but you leave your script wide open to sql injections (google it for more information) .. Adam Link to comment https://forums.phpfreaks.com/topic/131166-solved-update-query-not-updating-row/#findComment-681018 Share on other sites More sharing options...
Presto-X Posted November 3, 2008 Author Share Posted November 3, 2008 Thanks for the reply MrAdam, 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 'order='1', target='_parent' WHERE id='1'' at line 1 Link to comment https://forums.phpfreaks.com/topic/131166-solved-update-query-not-updating-row/#findComment-681022 Share on other sites More sharing options...
Mchl Posted November 3, 2008 Share Posted November 3, 2008 'order' is a reserved MySQL word. If you want to use it, you have to enclose it in `` Link to comment https://forums.phpfreaks.com/topic/131166-solved-update-query-not-updating-row/#findComment-681024 Share on other sites More sharing options...
Presto-X Posted November 3, 2008 Author Share Posted November 3, 2008 'order' is a reserved MySQL word. If you want to use it, you have to enclose it in `` SWEET! Thanks Mchl, I changed order to sortorder, and all is well... Thanks again for your fast replys guys! Link to comment https://forums.phpfreaks.com/topic/131166-solved-update-query-not-updating-row/#findComment-681025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.