creativkook Posted April 9, 2006 Share Posted April 9, 2006 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.<?phprequire("_statusSessionHeader.php");require("dbheader.php");if(isset($_POST['update'])){ $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"); exit;}$order = mysql_fetch_array(mysql_query("SELECT * FROM orderStatus WHERE orderid = $_GET[orderid]"));echo(mysql_error());?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Update PC Repair Status</title></head><body><h2>Update PC Repair Status</h2><form method="post" action="<?=$_SERVER['PHP_SELF'];?>"><p>Status:</p><p><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><p>Comments:</p><p><textarea name="comments" rows="5" cols="45" ></textarea></p><p><input type="submit" name="update" value="Update Status" /></p></form></body></html> Link to comment https://forums.phpfreaks.com/topic/6920-update-statement-not-working/ Share on other sites More sharing options...
IceHawk Posted April 9, 2006 Share Posted April 9, 2006 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. Link to comment https://forums.phpfreaks.com/topic/6920-update-statement-not-working/#findComment-25133 Share on other sites More sharing options...
creativkook Posted April 9, 2006 Author Share Posted April 9, 2006 The $_GET[orderid] is coming from the previous page, being passed from the header and query. Link to comment https://forums.phpfreaks.com/topic/6920-update-statement-not-working/#findComment-25139 Share on other sites More sharing options...
SomeGuy1337 Posted April 9, 2006 Share Posted April 9, 2006 <form method="post" action="<?=$_SERVER['PHP_SELF'];?>">wat ezactly is the action value on teh form?unless it has the page.php?orderid=5then it cant submit that to the script when it postswhen u post hte form it makes a brand new request to the server so any $GET information is lost unelss u pass it along againphp_self will contain teh direcotyr structure and the filename, not the request uri (which contain the $_GET arguemnts) Link to comment https://forums.phpfreaks.com/topic/6920-update-statement-not-working/#findComment-25200 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.