HDFilmMaker2112 Posted November 24, 2011 Share Posted November 24, 2011 I need help with the below MySQL query. I have two tables, with some information in one table that is needed to update the second table. The below is not update the table: elseif($_GET['forgot']=="password"){ if(email_verify($email)){ $new_password =& generatePassword(); $username=sanitize($_POST['username']); $newpass=kam3($new_password); $investors_forgot_password_sql1="UPDATE members SET password='$newpass' FROM application, members WHERE application.id=members.application_id AND username='$username' AND email='$email'"; $investors_forgot_password_result1=mysql_query($investors_forgot_password_sql1) or die(mysql_error()); $investors_forgot_password_num_rows1=mysql_affected_rows(); if($investors_forgot_password_num_rows1==1){ $content.='<p class="center">New password generated. It has been emailed to the email address provided.</p><br />'; $message='Some one (hopefully you) requested a new password be generated for your account on Make the Movie Happen. Below is the newly generated password: Password: '.$new_password.' Once you log-in, please change your password. Thank You, Make the Movie Happen Support Team '; mail($email, 'Make the Movie Happen - New Investor Password', $message, 'From: general@makethemoviehappen.com'); } else{ header("Location: ./index.php?investors=forgot&e=1"); } } else{ header("Location: ./index.php?investors=forgot&e=2"); } } The mysql_error(); returns nothing. Quote Link to comment https://forums.phpfreaks.com/topic/251723-using-one-table-to-update-another/ Share on other sites More sharing options...
phpSensei Posted November 24, 2011 Share Posted November 24, 2011 UPDATE table1,table2 SET table1.col=a,table2.col2=b WHERE items.id=month.id; This is more of a mysql question, it shouldn't be posted here, your query is all wrong. You can even use a JOIN statement. Quote Link to comment https://forums.phpfreaks.com/topic/251723-using-one-table-to-update-another/#findComment-1290943 Share on other sites More sharing options...
HDFilmMaker2112 Posted November 24, 2011 Author Share Posted November 24, 2011 Still not working. UPDATE members, application SET password='$newpass' WHERE application.id=members.application_id AND username='$username' AND email='$email' I've also tried: UPDATE members INNER JOIN application ON application.id=members.application_id SET password='$newpass' WHERE members.username='$username' AND application.email='$email' No luck. Quote Link to comment https://forums.phpfreaks.com/topic/251723-using-one-table-to-update-another/#findComment-1290948 Share on other sites More sharing options...
HDFilmMaker2112 Posted November 24, 2011 Author Share Posted November 24, 2011 my issue was the elseif statement at the beginning. Should have been $_GET['get']=="password". PHP issue not Mysql. UPDATE $tbl_name11, $tbl_name10 SET password='$newpass' WHERE application.id=members.application_id AND username='$username' AND email='$email' (I know that wouldn't have been possible to figure out from the excerpt that I posted.) Quote Link to comment https://forums.phpfreaks.com/topic/251723-using-one-table-to-update-another/#findComment-1291015 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.