 |
|
|
03-30-2005, 08:34 PM
|
Mailing Problem
|
Posts: 24
Location: Panama city Florida
|
Having a slight problem:
Now, to start off with, this script was origionally written by me several years ago, it has worked since then, and has not been modified. However, in the past couple of weeks it has stopped working correctly, I suspect that it is because of an update to PHP on the server, but I can not find the error. The problem is as follows:
When I send out my newsletter, it is sent two times. Once in normal format, and once it a format which does not have any of the variables included, The following three code snippets are 1: of my code, 2: The way the first (correct) e-mail looks, 3: the way the 2nd (incorrect) e-mail looks
PHP Code:
<br><table class="innertable" cellpadding=4 cellspacing=0 width="95%" align=center>
<tr>
<td valign=top>
<h2 align=left class="jokelistheader">Send Daily Joke</h2>
<?php
// remove existing html formatting
$ad1 = str_replace("<br />", "", $ad1);
$ad2 = str_replace("<br />", "", $ad2);
$ad3 = str_replace("<br />", "", $ad3);
$joke1 = str_replace("<br />", "", $joke1);
$joke2 = str_replace("<br />", "", $joke2);
//insert my own html formatting
$ad1 = nl2br($ad1);
$joke1 = nl2br($joke1);
$ad2 = nl2br($ad2);
$joke2 = nl2br($joke2);
$ad3 = nl2br($ad3);
$date = date("n-j-y");
$archive = mysql_query("INSERT INTO `list_archive` ( `id` , `ad1` , `joke1title` , `joke1` , `ad2` , `joke2title` , `joke2` , `ad3` , `date` )
VALUES (
'', '$ad1', '$joke1title', '$joke1', '$ad2', '$joke2title', '$joke2', '$ad3', '$date'
)");
echo mysql_error();
$ad3 = stripslashes($ad3);
$joke2 = stripslashes($joke2);
$ad2 = stripslashes($ad2);
$joke1 = stripslashes($joke1);
$joke2title = stripslashes($joke2title);
$joke1title = stripslashes($joke1title);
$ad1 = stripslashes($ad1);
$result = mysql_query("SELECT * FROM joke_mail_list ORDER BY id DESC");
while ($row = mysql_fetch_array($result)) {
/* subject */
$subject = "Daily Joke From GoldenJokes $date";
/* message */
$message = "
<html>
<head>
<title>$website_title</title>
</head>
<body>
<h1 align=center>Daily Joke From GoldenJokes</h1>
<br><br>
$ad1
<br><br>--------------------------------------------------
<br><br>
<h2>$joke1title</h2>
<br>
$joke1
<br><br>
--------------------------------------------------<br><br>
$ad2
<br><br>--------------------------------------------------
<br><br>
<h2>$joke2title</h2>
<br>
$joke2
<br><br>
--------------------------------------------------<br><br>
$ad3
<br><br><br>
************************************************<BR>
THIS MESSAGE WAS SENT TO YOU BECAUSE YOU OR SOMEONE USING YOUR E-MAIL ADDRESS SUBSCRIBED TO THE DAILY JOKE AT <a href=\"http://www.goldenjokes.com\">GoldenJokes.com</a> IF YOU WOULD LIKE TO BE UN-SUBSCRIBED FROM THIS MAILING LIST PLEASE GO TO <a href=\"http://www.goldenjokes.com?action=unsubscribe&email=$row[email]\">http://www.goldenjokes.com?action=unsubscribe&email=$row[email]</a>
</body>
</html>
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r \n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r \n";
/* additional headers */
$headers .= "From: GoldenJokes.com <webmaster@goldenjokes.com>\r \n";
/* and now mail it */
$mail = mail("$row[email]", "$subject", "$message", "$headers");
print("$row[id]. $row[email]<br>");
}
?>
</td>
</tr>
</table>
Quote:
Daily Joke From GoldenJokes
Please excuse me if the daily joke is being sent to you multiple times in a day, it is a problem with the script that I am trying to work out, please stick with me.
Thanks
Jackson
--------------------------------------------------
Puzzle
One night three blondes go into this restruant. The waiter escorts them to their seats and takes their drink orders. As he leaves he hears them excitingly congradulating eachother on a job well done. The waiter comes back and serves them their drinks. They're still very excited and talking about the same thing. Not trying to be impolite, the waiter asks,"I've overheard you guys congradulating eachother on something. If you don't mind, would you tell me what it is?"
"Of course we don't mind",replies one blonde.
"We just finished a puzzle", says another blonde.
"OK?...is that why your so excited?", the waiter asks.
"Well that's not the whole thing, replies the third blonde. It has only taken us 3 DAYS!"
Getting kind of annoyed the waiter says, " You guys are so excited because you finished a puzzle in 3 days!?!?!"
"Of course, the blondes replied. Wouldn't you be excited if you finished a puzzle in 3 days when the box said 3-5 years?!?
--------------------------------------------------
Random AD
--------------------------------------------------
No wonder the english language is so hard to learn
* We polish the Polish furniture.
* He could lead if he would get the lead out.
* A farm can produce produce.
* The dump was so full it had to refuse refuse.
* The soldier decided to desert in the desert.
* The present is a good time to present the present.
* At the Army base, a bass was painted on the head of a bass drum.
* The dove dove into the bushes.
* I did not object to the object.
* The insurance for the invalid was invalid.
* The bandage was wound around the wound.
* There was a row among the oarsmen about how to row.
* They were too close to the door to close it.
* The buck does funny things when the does are present.
* They sent a sewer down to stitch the tear in the sewer line.
* To help with planting, the farmer taught his sow to sow.
* The wind was too strong to wind the sail.
* After a number of Novocain injections, my jaw got number.
* I shed a tear when I saw the tear in my clothes.
* I had to subject the subject to a series of tests.
* How can I intimate this to my most intimate friend?
* I spent last evening evening out a pile of dirt.
--------------------------------------------------
Random Ad
************************************************
THIS MESSAGE WAS SENT TO YOU BECAUSE YOU OR SOMEONE USING YOUR E-MAIL ADDRESS SUBSCRIBED TO THE DAILY JOKE AT GoldenJokes.com IF YOU WOULD LIKE TO BE UN-SUBSCRIBED FROM THIS MAILING LIST PLEASE GO TO http://www.goldenjokes.com?action=un...aining@msn.com
|
Quote:
Daily Joke From GoldenJokes
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------
************************************************
THIS MESSAGE WAS SENT TO YOU BECAUSE YOU OR SOMEONE USING YOUR E-MAIL ADDRESS SUBSCRIBED TO THE DAILY JOKE AT GoldenJokes.com IF YOU WOULD LIKE TO BE UN-SUBSCRIBED FROM THIS MAILING LIST PLEASE GO TO http://www.goldenjokes.com?action=un...aining@msn.com
|
Thanks in advance for your help!
|
|
|
|
03-31-2005, 12:37 AM
|
|
Posts: 6
|
My suggestion would be to Form your $message by adding to the the message variable for each line, like you did with the headers. So something like...
PHP Code:
$message = "<html>";
$message .= "<head>";
$message .= "<title>$website_title</title>";
...
__________________
Ash Nazg....
|
|
|
|
03-31-2005, 01:50 PM
|
|
Posts: 297
|
jasong, i'm not sure this would make much difference - the problem is that it is sending the email to users more than once, when it should not.
After looking at your code, I dont see anything wrong with it, nothing that stands out anyway. I would suggest seeing if the script throws up an error after the line
Code:
$result = mysql_query("SELECT * FROM joke_mail_list ORDER BY id DESC");
since you've done it when storing the email.
Have you also tried testing the script using a different maillist (back-up your old one, and then drop it, add in a couple of your own email addresses, but not two of the same! and then trying to see if that works). If it does it could be that the script can't handle the amount of people in the list, or someone somewhere along the line has managed to place PHP code when signing up - just to bugger you up completely.
My other suggestion, and this is just me being real picky, is changing the line:
Code:
$result = mysql_query("SELECT * FROM joke_mail_list ORDER BY id DESC");
try specifying the exact fields you need, and also take out the ORDER command, as this may be slowing things down. But thats just me being pedantic!
Hope this helps somehow???
|
|
|
|
03-31-2005, 05:02 PM
|
|
Posts: 24
Location: Panama city Florida
|
thanks, I'll try that and tell you how it turns out!
edit:
ok, I did what you said about emptying out the db and putting just a couple in... with 3 of my own e-mail addresses, I'm getting one correct one, and two of the incorrect ones for each email address.
also, the error handler showed up nothing.
any idea why? what would make it send multiple times anyway?
Last edited by brainintraining; 03-31-2005 at 05:21 PM..
|
|
|
|
03-31-2005, 07:08 PM
|
|
Posts: 297
|
ok, another suggestion, this time to slow down the loop. Within your loop you have set the $Message and $Header variable, everytime the loop goes round, is this really needed? Just comparing to my own multiple mail handlers and I always set things like this (elements that will be identical for each mailing address) outside of the loop. This time, try this:
PHP Code:
<br><table class="innertable" cellpadding=4 cellspacing=0 width="95%" align=center>
<tr>
<td valign=top>
<h2 align=left class="jokelistheader">Send Daily Joke</h2>
<?php
// remove existing html formatting
$ad1 = str_replace("<br />", "", $ad1);
$ad2 = str_replace("<br />", "", $ad2);
$ad3 = str_replace("<br />", "", $ad3);
$joke1 = str_replace("<br />", "", $joke1);
$joke2 = str_replace("<br />", "", $joke2);
//insert my own html formatting
$ad1 = nl2br($ad1);
$joke1 = nl2br($joke1);
$ad2 = nl2br($ad2);
$joke2 = nl2br($joke2);
$ad3 = nl2br($ad3);
$date = date("n-j-y");
$archive = mysql_query("INSERT INTO `list_archive` ( `id` , `ad1` , `joke1title` , `joke1` , `ad2` , `joke2title` , `joke2` , `ad3` , `date` )
VALUES (
'', '$ad1', '$joke1title', '$joke1', '$ad2', '$joke2title', '$joke2', '$ad3', '$date'
)");
echo mysql_error();
$ad3 = stripslashes($ad3);
$joke2 = stripslashes($joke2);
$ad2 = stripslashes($ad2);
$joke1 = stripslashes($joke1);
$joke2title = stripslashes($joke2title);
$joke1title = stripslashes($joke1title);
$ad1 = stripslashes($ad1);
/* subject */
$subject = "Daily Joke From GoldenJokes $date";
/* message */
$message = "
<html>
<head>
<title>$website_title</title>
</head>
<body>
<h1 align=center>Daily Joke From GoldenJokes</h1>
<br><br>
$ad1
<br><br>--------------------------------------------------
<br><br>
<h2>$joke1title</h2>
<br>
$joke1
<br><br>
--------------------------------------------------<br><br>
$ad2
<br><br>--------------------------------------------------
<br><br>
<h2>$joke2title</h2>
<br>
$joke2
<br><br>
--------------------------------------------------<br><br>
$ad3
<br><br><br>
************************************************<BR>
THIS MESSAGE WAS SENT TO YOU BECAUSE YOU OR SOMEONE USING YOUR E-MAIL ADDRESS SUBSCRIBED TO THE DAILY JOKE AT <a href=\"http://www.goldenjokes.com\">GoldenJokes.com</a> IF YOU WOULD LIKE TO BE UN-SUBSCRIBED FROM THIS MAILING LIST PLEASE GO TO <a href=\"http://www.goldenjokes.com?action=unsubscribe&email=$row[email]\">http://www.goldenjokes.com?action=unsubscribe&email=$row[email]</a>
</body>
</html>
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r \n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r \n";
/* additional headers */
$headers .= "From: GoldenJokes.com <webmaster@goldenjokes.com>\r \n";
/* and now mail it */
$result = mysql_query("SELECT * FROM joke_mail_list ORDER BY id DESC");
while ($row = mysql_fetch_array($result)) {
$SendToEmail = $row['email'];
$mail = mail("$SendToEmail", "$subject", "$message", "$headers");
print("$row['id']. $row['email']<br>");
}
Can you see what i've done here? Moved the sql query as well as the loop down, after declaring and setting the variables.
Also, I removed $row['email'] out of the mail() command, just to make sure that this was not causing a problem also, by all means change it back if everything works, im just trying to really fiddle with the script to see what i can get to work.
Hope this helps!
Last edited by leavethisplace; 03-31-2005 at 07:09 PM..
Reason: clearing things up
|
|
|
|
03-31-2005, 07:39 PM
|
|
Posts: 24
Location: Panama city Florida
|
thanks for your reply, but for some reason, once again, without any changes, just before your reply, the script started working again... (maybe a server problem for the past 2 weeks?)
However, now I'm having another problem with nl2br... oh well, I'll see if I can figure it out before posting here again... thanks
|
|
|
|
|
« Reply to Mailing Problem
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|