Jump to content

Archived

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

creativkook

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.


<?php

require("_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>

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.