Anthony Rodriguez wrote: > The following php script successfully e-mails both messages but it doesn't > update in the table "scr_149" the column "notified". Why? > > <?php > $connection=mysql_connect("localhost","wagner","123") or die ("No > connection!"); > > $db=mysql_select_db("sbwresearch_com",$connection) or die ("No database!"); > > $message_1=" > > Congratulations!\n\n > You've qualified to take the online survey # 149.\n\n > To take the survey, go to www.sbwresearch.com and click on Survey / Tests.\n\n > > "; > > $message_2=" > > Sorry!\n\n > You've not qualified to take the online survey # 149.\n\n > We'll notify you by e-mail of upcoming screeners. > > "; > $qry_1="select * from scr_149 where q05a!=\"0\" && notified=\"n\""; > $qry_2="update scr_149 set notified='y' where username='$username'";
^ What's the value of $username here? > $result_1=mysql_query($qry_1,$connection) or die ("No query # 1!"); > while ($row_1=mysql_fetch_array($result_1, MYSQL_ASSOC)) > { > $username=$row_1["username"]; ^ Because setting $username here is too late... You should define $qry_2 after defining $username (move that line here). > > $e_mail=$row_1["e_mail"]; > mail("$e_mail", > "News from SBW Research", > "$message_1", > "From:SBW Research <[EMAIL PROTECTED]>\n"); > $result_2=mysql_query($qry_2,$connection) or die ("No query # 2!"); > }; > > mysql_free_result($result_1); > > $qry_3="select * from scr_149 where q05a=\"0\" && notified=\"n\""; > $qry_4="update scr_149 set notified=\"y\" where username='$username'"; ^ Same thing here... > > $result_3=mysql_query($qry_3,$connection) or die ("No query # 3!"); > while ($row_2=mysql_fetch_array($result_3, MYSQL_ASSOC)) > { > $username=$row_2["username"]; ^ ...being moved here. > > $e_mail=$row_2["e_mail"]; > mail("$e_mail", > "News from SBW Research", > "$message_2", > "From:SBW Research <[EMAIL PROTECTED]>\n"); > $result_4=mysql_query($qry_4,$connection) or die ("No query # 4!"); > }; > > @mysql_free_result($result_3); > @mysql_close($connection); > header ("location:done.htm"); > exit; > ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]