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! Quote Link to comment 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()); Quote Link to comment 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'; ?> Quote Link to comment Share on other sites More sharing options...
jbrill Posted July 18, 2007 Author Share Posted July 18, 2007 ??? Quote Link to comment 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. 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.