TheHarriets Posted July 30, 2012 Share Posted July 30, 2012 Hi! I'm new here and pretty much an amateur with PHP. For my website, I have a PHP CRON script which when run should send an e-mail to all users on my site whose profile will expire in 2 days time, to remind them to renew. This is the script: 1 <? 2 mysql_connect("localhost","myco_mycoabc","test@123"); 3 mysql_select_db("myco_mycoabc"); 4 5 $sql="select * from tbl_signup_user WHERE DATEDIFF(endDate, now()) = 2 "; 6 $rs=mysql_query($sql); 7 while($row=mysql_fetch_array($rs)) 8 { 9 10 $userEmail=$row['email']; 11 $userName=$row['user_name']; 12 $firstName=$row['first_name']; 13 $end_Date=date("l F d, Y",strtotime($row['endDate'])); 14 $from="support@myco.co.uk"; 15 $message = "This is a multi-part message in MIME format.\n\n" . 16 "--{$mime_boundary}\n" . 17 "Content-Type: text/html; charset=\"iso-8859-1\"\n" . 18 "Content-Transfer-Encoding: 7bit\n\n" . 19 $message . "\n\n"; 20 $msg .="Hi ".$firstName." \n\n As you may be aware your ".$userName." profile on www.myco.co.uk is due to expire on ".$end_Date."." . "\n\n"; 21 $msg .="If you wish to continue being a member of our directory, please log into your account, select ?Renew my Profile? and choose your payment option." . "\n\n"; 22 $msg .="We are now one of the best directories in the UK, giving excellent value for money:" . "\n\n"; 23 $msg .="+ Good quality photo gallery" . "\n"; 24 $msg .="+ Easy to edit your profile" . "\n"; 25 $msg .="+ All major debit & credit cards accepted" . "\n\n"; 26 $msg .="If you have any questions please let us know." . "\n\n"; 27 $msg .="All the best" . "\n\n"; 28 29 $msg .="My Company Support" . "\n"; 30 $msg .="www.myco.co.uk" . "\n"; 31 32 33 ; 34 $headers = "From:" . $from; 35 mail($userEmail, "My Company subscription",$msg,$headers); 36 } 37 ?> However, the script is sending the firstname and username of all selected members in the same e-mail in some of the e-mails! i.e. rather than each member who expires in 2 days just getting the e-mail personalised with their firstname and username, at the bottom it then appends it with the same e-mail with the firstname and username of the other members expiring in 2 days time! Please could someone tell me where I'm going wrong and how to fix it? Many thanks! Steve Quote Link to comment https://forums.phpfreaks.com/topic/266457-script-to-send-e-mails-is-sending-wrong-info/ Share on other sites More sharing options...
Jessica Posted July 30, 2012 Share Posted July 30, 2012 You have $message and then $msg, and you send $msg. Change the $message to $msg and you should be good. Quote Link to comment https://forums.phpfreaks.com/topic/266457-script-to-send-e-mails-is-sending-wrong-info/#findComment-1365448 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.