hi i am having a problem performing an insert from my php code. Here is the code i am using $q = "UPDATE tbl_users SET username=$username, password=$password WHERE user_ID = $user_ID"; mysql_query($q, $connection) or die(mysql_error()); Code (markup): now i am getting the error Unknown column 'gaby' in 'field list'. I cannot understand why i get this error as far as i can see i have used the correct syntax for an update and now it is telling me that gaby doesnt exist, which in this case is the data not the field name. any help pls?
ok thanks solved that however the fields in my db are still not being updated, I think I need some futher help, here is the code i am using at the moment: <?php require_once("config.php"); // if data has been submitted save it in db and redirect to user listing if ($_POST["submit"]) { $user_ID = $_POST["user_ID"]; $username = $_POST["username"]; $password = $_POST["password"]; $q = "UPDATE tbl_users SET username='$username', password='$password' WHERE user_ID = '$user_ID'"; mysql_query($q, $connection) or die(mysql_error()); //$id = mysql_insert_id($connection); header("Location: users.php"); // if user_ID present in URL search for that record and display page in edit format } else if ($_GET["user_ID"]) { $user_ID = $_GET["user_ID"]; $q = "SELECT * FROM tbl_users WHERE user_ID = '$user_ID'"; $result = @mysql_query($q, $connection) or die(mysql_error()); $user = mysql_fetch_array($result); $smarty->assign('user', $user); $smarty->display("users-edit.tpl"); } ?> Code (markup):
You need to check your table structure. You could possibly make it dump mysql_error when it tries to insert. One trick I use is writing the insert queries, and then try them in phpmyadmin.