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 Link to comment https://forums.phpfreaks.com/topic/188546-add-data-to-table/ 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? Link to comment https://forums.phpfreaks.com/topic/188546-add-data-to-table/#findComment-995424 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); ?> Link to comment https://forums.phpfreaks.com/topic/188546-add-data-to-table/#findComment-995425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.