Jump to content

datamodeler

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

datamodeler's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=372453:date=May 8 2006, 07:28 PM:name=John Dunne)--][div class=\'quotetop\']QUOTE(John Dunne @ May 8 2006, 07:28 PM) [snapback]372453[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hey guys, I can't seem to get this script to update a record in my MySQL database for me. It takes input from a form (POST) and assigns them variables. It then connects to the database, assigns the query to $query, and runs the query inside of an if statement to test if it worked. But I keep getting an error and when I check the database it hasn't updated. Here's part of the code: $query = "UPDATE Users SET AIM = '$AIM', YIM = '$YIM', MSN = '$MSN', website = '$website', Location = '$location', RW_Expirence = '$RW_Expirence', VATSIM ID = '$VATSIM', Auto = '$auto' WHERE `First` = '$First' AND Last = '$Last'"; if (mysql_query($query)) { print "Your profile has been updated."; ?> <form> <input type="button" value="Run Again" onClick="window.location = 'profile.php'"></form> <?php } else { print ("Uh Oh! There was an error, please try again."); ?> <form><input type="button" value="Run Again" onClick="window.location = 'profile.php'"></form> <?php } mysql_close(); ?> Any help is appreciated, thanks! [/quote] The correct form for an update statement is: update tablename set columnname = value [, columnname = value ...] where primarykey = pk_value and you left off the last part.
×
×
  • Create New...

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.