Jump to content


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


Update statement not working

Recommended Posts

I'm having problems with this code, it's not updating at all, giving me an error telling me that I have an error in my mysql syntax. If anyone can see what I can't, that would be really appreciated.



$status = strip_tags($_POST['status']);
$comments = strip_tags($_POST['comments']);

mysql_query("UPDATE orderStatus SET status = '$status', comments = '$comments' WHERE orderid = $_GET[orderid]");

header("location: statusSet.php");


$order = mysql_fetch_array(mysql_query("SELECT * FROM orderStatus WHERE orderid = $_GET[orderid]"));



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Update PC Repair Status</title>
<h2>Update PC Repair Status</h2>

<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">

<input type="radio" name="status" value="checkinshelf" /> Check-in shelf
<input type="radio" name="status" value="onthebench" /> On the bench
<input type="radio" name="status" value="ongoingdiag" /> Ongoing diagnostic
<input type="radio" name="status" value="onholdpartsonorder" /> On hold - parts on order
<input type="radio" name="status" value="waitingoncustomerresponse" /> Waiting on customer response
<input type="radio" name="status" value="finished" /> Finished
<p><textarea name="comments" rows="5" cols="45" ></textarea></p>

<p><input type="submit" name="update" value="Update Status" /></p>



Share this post

Link to post
Share on other sites
Where is $_GET['orderid'] coming from exactly? The form you provided does not carry any field named 'orderid' so even if orderid is set in $_GET when submitting the form, it will not be carried over. Try adding a hidden field to the form named 'orderid' and pass in the value of $_GET['orderid'] to it and try again. This is causing $_GET['orderid'] to be blank, which is probably causing the queries to throw an error.

Share this post

Link to post
Share on other sites
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">

wat ezactly is the action value on teh form?
unless it has the page.php?orderid=5

then it cant submit that to the script when it posts
when u post hte form it makes a brand new request to the server so any $GET information is lost unelss u pass it along again

php_self will contain teh direcotyr structure and the filename, not the request uri (which contain the $_GET arguemnts)

Share this post

Link to post
Share on other sites


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.