PDA

View Full Version : UPDATE command (php/mySQL)



Yeldarb
February 28th, 2004, 12:40 AM
I need some help in implementing the UPDATE command. I can't figure out why it isn't working. The point is to update the values in the database from values submitted in a form. Here's my code, I would greatly appreciate it if someone could tell me what is wrong with it. I know that it is executing because it prints out the echo.


if($theName) {

$query = "UPDATE orders SET address='$address', city='$city', state='$state', zip='$zip', phone='$phone', birthdate='$birthdate', lastPresc='$prescDate', lastOrder='$lastOrder', rtBrand='$rtBrand', ltBrand='$ltBrand', rtBaseCurve='$rtBaseCurve', rtDiameter='$rtDiameter', ltDiameter='$ltDiameter', rightPower='$rtPower', leftPower='$ltPower') WHERE username='$theName'";
$result = mysql_query($query);

echo "<i>$theName's data was updated successfully.</i><br><br>";

ahmed
February 28th, 2004, 12:47 AM
leftPower='$ltPower')

what's the ) for?

Yeldarb
February 28th, 2004, 12:49 AM
oooh, whoops, that was from when I was doing it wrong. I must have forgotten to take it out ;)

i'll try without it, thanks.

EDIT: YAY, it worked :D Thanks ahmed

ahmed
February 28th, 2004, 12:50 AM
haha, silly thing :P

Voetsjoeba
February 28th, 2004, 04:44 AM
Don't forget the ";" after your querystring !

ahmed
February 28th, 2004, 01:55 PM
it's actually optional voet, as long as you're passing only one query (you can't pass more than that anyway) :)

good practice though