Jump to content

[SOLVED] just a quick question..needing a quick answer :)


jbrill

Recommended Posts

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!

 

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());

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';
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.