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!

 

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.