mailing list question :/

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

$formset = mail("$sendmail[email][$x];

Multi-dimensional arrays are fun.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

grrrrrrrr..still does't work :(

Code: Select all

code:
$count = count($sendmailїemail]);
for ($x=0;$x<=$count;$x++)
&#123; // $formsent is line 77
$formset = mail("$sendmail&#1111;email]&#1111;$x]","$subject - News Letter","$message1","From:$get&#1111;mail]");
print("$sendmail&#1111;email]&#1111;$x]<br>");
&#125;

Code: Select all

errors:
Warning: Server Error in c:\apache\htdocs\phpmailinglist\main.php on line 76
qadeer_uk2001@yahoo.com&#1111;0]

Warning: Server Error in c:\apache\htdocs\phpmailinglist\main.php on line 76
qadeer_uk2001@yahoo.com&#1111;1]

Warning: Server Error in c:\apache\htdocs\phpmailinglist\main.php on line 76
qadeer_uk2001@yahoo.com&#1111;2]

Warning: Server Error in c:\apache\htdocs\phpmailinglist\main.php on line 76
qadeer_uk2001@yahoo.com&#1111;3]

Warning: Server Error in c:\apache\htdocs\phpmailinglist\main.php on line 76
qadeer_uk2001@yahoo.com&#1111;4]
wha am i doing wrong here? :oops:
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

Something bad?

What's on line 76? Or to be more precise, what's on line 75?

In fact, what's on lines 70 thru 80?
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

if(IsSet($send))
&#123;
$admininfo = "SELECT mail,Website FROM admin WHERE username='$admin'";
$getinfo = mysql_query($admininfo) or die("Error While geting admin information.");
$get = mysql_fetch_array($getinfo);
$re = mysql_query("SELECT `ID`, name, `email` FROM `members`");
$sendmail = mysql_fetch_array($re);
$message = stripcslashes($message);
$sendmail = mysql_fetch_array($re);

$count = count($sendmail&#1111;email]);
for ($x=0;$x<=$count;$x++)
&#123;
$message1 =  "$message
	
*****If you would to like to be removed from this list then please click on this link  $get&#1111;Website]/remove.php?name=$sendmail&#1111;name]&#1111;$x]&ID=$sendmail&#1111;ID]&#1111;$x], if you can't click it then copy and paste into your address bar.
******";

$formset = mail("$sendmail&#1111;email]&#1111;$x]","$subject - News Letter","$message1","From:$get&#1111;mail]");
print("$sendmail&#1111;email]&#1111;$x]<br>"); //email address check
&#125;
Print("<b>Email(s) Has Been Sent!</b>");
&#125;
that's all of it! and line 77 is the one with $formtset on it.
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

Just to make sure, try setting your message on a line-by-line basis so instead of making it span multiple lines, just do $message.="blah";

Oh, and try escaping the variables, so you have "blah".$get[Website]." type stuff.

Hmm... My brain is feeling a little fried right now, but i keep getting this urge to ask about whether array names in square brackets should be enclosed in quotes...
sav
Forum Newbie
Posts: 8
Joined: Mon Oct 21, 2002 7:29 pm

Post by sav »

qads wrote:

Code: Select all

$message1 =  "$message
Can you try to put ';' at the end of this ^^^ line? 8)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Why do you have two mysql_fetch_array() calls here?

Code: Select all

$sendmail = mysql_fetch_array($re); 
$message = stripcslashes($message); 
$sendmail = mysql_fetch_array($re);
The reason why it only returns the first email is probably because you only take one row of the result at a time when you use mysql_fetch_array(), you need to put it into a while loop if you want them all, try something like:

Code: Select all

if(isset($send)) { 
	$admininfo = "SELECT mail, Website FROM admin WHERE username='$admin'"; 
	$getinfo = mysql_query($admininfo) or die('Error While geting admin information.'); 
	$get = mysql_fetch_assoc($getinfo); 
	$message = stripslashes($message);
	
	$re = mysql_query("SELECT `ID`, name, `email` FROM `members`") or die('Could not select e-mails'); 
	while ($row = mysql_fetch_assoc($re)) {
		$message1 = $message;
		$message1 .=&lt;&lt;&lt;END
*****If you would to like to be removed from this list then please click on this link {$get&#1111;'Website']}/remove.php?name={$sendmail&#1111;'name']}&amp;ID={$sendmail&#1111;'ID']}, if you can't click it then copy and paste into your address bar. 
******
END;
		$formset = mail($sendmail&#1111;'email'], $subject.' - News Letter', $message1, 'From:'.$get&#1111;'mail']);
		echo $sendmail&#1111;'email'].'&lt;br /&gt;';
	}
	echo '&lt;b&gt;Email(s) Have Been Sent!&lt;/b&gt;';
}
Mac
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

sav...i am adding more text to $message1, so that's why i don't need a ;, it is at the end of it :P

twigletmac, 2nd array call was a typo, i removed it after posting message:roll:

i'll test this code out, thanks guys:)
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

nope..that did't work :?

but this :D

Code: Select all

$query = mysql_query("select email from members");
while($row = mysql_fetch_array($query))
&#123;
$email = $row&#1111;0];
mail($email, $subject, $message, $headers);
&#125;
print("Email Sent);
Post Reply