Jump to content


Update statement not working

  • Please log in to reply
3 replies to this topic

#1 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.



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



#2 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

  • 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

  • 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