Jump to content


Photo

Update statement not working


  • Please log in to reply
3 replies to this topic

#1 creativkook

creativkook
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 09 April 2006 - 02:47 AM

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...nsitional.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>


#2 IceHawk

IceHawk
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 09 April 2006 - 02:54 AM

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.
[a href="http://www.devtext.com" target="_blank"]DevText a community for all languages[/a]

#3 creativkook

creativkook
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 09 April 2006 - 03:18 AM

The $_GET[orderid] is coming from the previous page, being passed from the header and query.

#4 SomeGuy1337

SomeGuy1337
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 09 April 2006 - 01:57 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users