maestrodamuz Posted January 22, 2009 Share Posted January 22, 2009 I am developing a newsletter mailing application. On testing i discovered that the application doesnt send a mail to the most recent added email, I have tried to debug the script to no avail This is the script I am using mysql_select_db($database_gedu, $gedu); $query_users = "SELECT email FROM users ORDER BY sname DESC"; $users = mysql_query($query_users, $gedu) or die(mysql_error()); $row_users = mysql_fetch_assoc($users); $totalRows_users = mysql_num_rows($users); //create a From: mailheader $headers = "From:XXXXXXXXXXXX"; //loop through results and send mail while ($row = mysql_fetch_array($users)) { set_time_limit(0); $email = $row['email']; // content-type $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; mail("$email", stripslashes($_POST['subject']), stripslashes($_POST['body']), "$headers"); echo "Email has been sent to: $email<br>"; } Any help will be aapreciated. Quote Link to comment https://forums.phpfreaks.com/topic/142043-mailing-list-help/ Share on other sites More sharing options...
premiso Posted January 22, 2009 Share Posted January 22, 2009 $row_users = mysql_fetch_assoc($users); That is the line that is messing you up. Remove that and your script should work fine. Quote Link to comment https://forums.phpfreaks.com/topic/142043-mailing-list-help/#findComment-743810 Share on other sites More sharing options...
maestrodamuz Posted January 22, 2009 Author Share Posted January 22, 2009 $row_users = mysql_fetch_assoc($users); That is the line that is messing you up. Remove that and your script should work fine. Thank U premiso...it works now..I appreciate Quote Link to comment https://forums.phpfreaks.com/topic/142043-mailing-list-help/#findComment-743818 Share on other sites More sharing options...
premiso Posted January 22, 2009 Share Posted January 22, 2009 $row_users = mysql_fetch_assoc($users); That is the line that is messing you up. Remove that and your script should work fine. Thank U premiso...it works now..I appreciate If you want to know why, accessing that there set the pointer to be +1 so when you looped through it, it was under the impression you already accessed the first element. Anyhow I was just bored so figured I would explain it. Quote Link to comment https://forums.phpfreaks.com/topic/142043-mailing-list-help/#findComment-743819 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.