slj90 Posted January 15, 2010 Share Posted January 15, 2010 Hello, What would be the easiest way to enter the word 'Pistol' into my mysql table when the user presses a button? I came up with the following code as a guide to show you, however its coded incorrectly as i'm new to this.. <?php include ("connectionusers.php"); $ID = $_SESSION["authenticatedUser"] ; $ID = $_GET['ID'] ; $query = "INSERT INTO users WHERE ID = $ID (Weapon1) VALUES ('Pistol')"; $result = mysql_query ($query); ?> Thanks Quote Link to comment Share on other sites More sharing options...
x_filed2k Posted January 15, 2010 Share Posted January 15, 2010 Are you an insert a value or updating a value? Quote Link to comment Share on other sites More sharing options...
x_filed2k Posted January 15, 2010 Share Posted January 15, 2010 If you are insert a data you can try this... <?php include ("connectionusers.php"); $ID = $_SESSION["authenticatedUser"] ; $ID = $_GET['ID'] ; $query = "INSERT INTO `users`(`Weapon1`) VALUES (\"Pistol\")"; $result = mysql_query ($query); ?> or Updating a data. <?php include ("connectionusers.php"); $ID = $_SESSION["authenticatedUser"] ; $ID = $_GET['ID'] ; $query = "UDPATE `users` SET `Weapon1` = \"Pistol\" WHERE `ID` = \"${ID}\""; $result = mysql_query ($query); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.