Forum Moderators: coopster

Message Too Old, No Replies

Update MYSQL Entries

Can't use Update properly

         

briesm

6:56 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Hey, so I'm trying to update an entry WHERE order_NUM = $_GET['order']

This is throwing the script, how can I properly UPDATE the specified fields?

THanks in advance :)

$result = MYSQL_QUERY("UPDATE customerMaster WHERE order_Num = $_GET['order']
date= '$date',
territory= '$territory',
salesRep= '$salesRep',
repEmail= '$repEmail',
facility= '$facility',
address= '$address',
contact1= '$contact1',
department1= '$department1',
phone1= '$phone1',
fax1= '$fax1',
email1= '$email1',
contact2= '$contact2',
department2= '$department2',
phone2= '$phone2',
fax2= '$fax2',
email2= '$email2',
comments= '$comments',
gpo= '$gpo',
otherDiscounting='$otherDiscount'");

sned

7:02 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



The WHERE clause should be the last thing in the statement:

$result = MYSQL_QUERY("UPDATE customerMaster SET
date= '$date',
territory= '$territory',
salesRep= '$salesRep',
repEmail= '$repEmail',
facility= '$facility',
address= '$address',
contact1= '$contact1',
department1= '$department1',
phone1= '$phone1',
fax1= '$fax1',
email1= '$email1',
contact2= '$contact2',
department2= '$department2',
phone2= '$phone2',
fax2= '$fax2',
email2= '$email2',
comments= '$comments',
gpo= '$gpo',
otherDiscounting='$otherDiscount'
WHERE order_Num = $_GET['order']");

I think that will work ... of course, since there's been all sorts of threads on security lately, passing the $_GET['order'] directly to the query can be a bad thing ....

-sned

HeadBut

7:06 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Just a thought:

I always do it a little different and this should help you debug:

$MysqlMessage = "UPDATE customerMaster SET date= '$date',
territory= '$territory',
salesRep= '$salesRep',
repEmail= '$repEmail',
facility= '$facility',
address= '$address',
contact1= '$contact1',
department1= '$department1',
phone1= '$phone1',
fax1= '$fax1',
email1= '$email1',
contact2= '$contact2',
department2= '$department2',
phone2= '$phone2',
fax2= '$fax2',
email2= '$email2',
comments= '$comments',
gpo= '$gpo',
otherDiscounting='$otherDiscount
WHERE order_Num = $_GET['order']";
$result = MYSQL_QUERY($MysqlMessage);

and for debug look at the query like this:

echo $MysqlMessage;

maybe someone else can clean that up a little
hope that helps