jbrill Posted July 18, 2007 Share Posted July 18, 2007 If i have the url ( this url is created from a form on the previous page): http://www.myurl.com/admin/updateinfo.php?jobid=1&stepid=2&actual_time=10 why is this code giving me an error, i would like this code to update the database at the actual_time field: <? include 'admin_header.php'; $actual_time = $_GET['actual_time']; if($_SESSION['type'] == "admin") { $sql="UPDATE guestbook (actual_time) VALUES ('".$actual_time."')"; $result=mysql_query($sql); //check if query successful if($result){ echo "success"; echo"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=admin_modprocess.php?idr=$quote_id&table=jobs\">"; } else { echo "ERROR"; } mysql_close(); } include 'admin_footer.php'; thanks guys! Link to comment https://forums.phpfreaks.com/topic/60633-solved-just-a-quick-questionneeding-a-quick-answer/ Share on other sites More sharing options...
akitchin Posted July 18, 2007 Share Posted July 18, 2007 your SQL statement syntax for the UPDATE query is wrong. check the MySQL manual for the correct syntax: http://dev.mysql.com/doc/refman/4.1/en/sql-syntax.html essentially, you must specify each column explicitly in an UPDATE statement, as opposed to the INSERT syntax: UPDATE table SET field1='value1', field2='value2' ... a quick way to debug scripts involving MySQL queries that aren't executing is to add an or die() clause at the end: $result=mysql_query($sql) or die('Error with the query: '.mysql_error()); Link to comment https://forums.phpfreaks.com/topic/60633-solved-just-a-quick-questionneeding-a-quick-answer/#findComment-301657 Share on other sites More sharing options...
jbrill Posted July 18, 2007 Author Share Posted July 18, 2007 ok, so i have it updating now.. now it is updating for all entries in the table and i want to limit it to the correct one so now i have this code: <? include 'admin_header.php'; $actual_time = $_GET['actual_time']; $jobid = $_GET['jobid']; $idr = $_GET['idr']; if($_SESSION['type'] == "admin") { $sql="UPDATE guestbook SET actual_time='$actual_time' WHERE id='$idr' AND quote_id='$jobid'"; $result=mysql_query($sql) or die('Error with the query: '.mysql_error()); //check if query successful if($result){ echo "success"; echo"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"4; URL=admin_modprocess.php?idr=$jobid&table=jobs\">"; } else { echo "ERROR"; } mysql_close(); } include 'admin_footer.php'; ?> Link to comment https://forums.phpfreaks.com/topic/60633-solved-just-a-quick-questionneeding-a-quick-answer/#findComment-301719 Share on other sites More sharing options...
jbrill Posted July 18, 2007 Author Share Posted July 18, 2007 ??? Link to comment https://forums.phpfreaks.com/topic/60633-solved-just-a-quick-questionneeding-a-quick-answer/#findComment-301735 Share on other sites More sharing options...
akitchin Posted July 18, 2007 Share Posted July 18, 2007 what's the problem? is it still updating every entry in the table? if so, check what your $idr and $job_id values are by echoing them before running the statement. Link to comment https://forums.phpfreaks.com/topic/60633-solved-just-a-quick-questionneeding-a-quick-answer/#findComment-301738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.