DeanWhitehouse Posted April 23, 2008 Share Posted April 23, 2008 how can i insert into a certain row in my database mysql_query("INSERT INTO `$user` (user_name, user_password, user_email) VALUES ('$user_name','$userPswd','$user_email')") this is the code, i want to use there user_id and/or there user_name to find the row to insert into Quote Link to comment Share on other sites More sharing options...
Spaceman-Spiff Posted April 23, 2008 Share Posted April 23, 2008 Is what you need to use: the UPDATE statement? mysql_query("UPDATE `$user` SET user_email = '$something' WHERE user_name = $username"); http://dev.mysql.com/doc/refman/5.0/en/update.html Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 23, 2008 Author Share Posted April 23, 2008 so would this be right, to edit details for this getting the row from there id no. $user_id = $_SESSION['user_id']; mysql_query("UPDATE SET user_id = '$user_id' WHERE user_name = $user_name AND user_password = $user_password AND user_email = $user_email") Quote Link to comment Share on other sites More sharing options...
Spaceman-Spiff Posted April 23, 2008 Share Posted April 23, 2008 You got it backwards.. $user_id = $_SESSION['user_id']; mysql_query("UPDATE tablename SET user_name = '$user_name', user_password = '$user_password', user_email = '$user_email' WHERE user_id = '$user_id'"); You will need to enclose strings in single quotes. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 23, 2008 Author Share Posted April 23, 2008 o rite, so WHERE is what row? Quote Link to comment Share on other sites More sharing options...
Spaceman-Spiff Posted April 23, 2008 Share Posted April 23, 2008 Correct. UPDATE [table name] SET [the col names and values] WHERE [your conditions] 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.