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. 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. 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 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. Link to comment https://forums.phpfreaks.com/topic/142043-mailing-list-help/#findComment-743819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.