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 Link to comment https://forums.phpfreaks.com/topic/102435-solved-mysql-insert-into-row/ 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 Link to comment https://forums.phpfreaks.com/topic/102435-solved-mysql-insert-into-row/#findComment-524560 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") Link to comment https://forums.phpfreaks.com/topic/102435-solved-mysql-insert-into-row/#findComment-524568 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. Link to comment https://forums.phpfreaks.com/topic/102435-solved-mysql-insert-into-row/#findComment-524574 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? Link to comment https://forums.phpfreaks.com/topic/102435-solved-mysql-insert-into-row/#findComment-524576 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] Link to comment https://forums.phpfreaks.com/topic/102435-solved-mysql-insert-into-row/#findComment-525230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.