Zepo. Posted December 8, 2007 Share Posted December 8, 2007 This isnt working for some reason, and im not sure if you can email in loops like this...... Loop $emailq=mysql_query("SELECT name,email FROM teams"); while(list($name,$email)=mysql_fetch_row($emailq)){ $email[toname] ="$name"; $email[toemail] ="$email"; $email[subject] ="$send[subject]"; $email[fromname] ="{$_SESSION['rights']}"; $email[fromemail] ="$config[sitemail]"; $email[replyname] ="$name"; $email[replyemail] ="$email"; $email[body] ="$send[body]"; email($email); $sent.="Sending To $name..........Sent<br />"; } Email Function //E-Mail Function function email($email){ mail("$email[toname] <$email[toemail]>","$email[subject]","$email[body]", "From: $email[fromname] <$email[fromemail]>\nReply-To: $email[replyname] <$email[replyemail]>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion()); } No errors. Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted December 8, 2007 Share Posted December 8, 2007 Your function is calling a variable that gets defined in the actual code try: <?php $emailq=mysql_query("SELECT name,email FROM teams"); function email($email){ mail("$email[toname] <$email[toemail]>","$email[subject]","$email[body]", "From: $email[fromname] <$email[fromemail]>\nReply-To: $email[replyname] <$email[replyemail]>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion()); } while(list($name,$email)=mysql_fetch_row($emailq)){ $email[toname] ="$name"; $email[toemail] ="$email"; $email[subject] ="$send[subject]"; $email[fromname] ="{$_SESSION['rights']}"; $email[fromemail] ="$config[sitemail]"; $email[replyname] ="$name"; $email[replyemail] ="$email"; $email[body] ="$send[body]"; email($email); $sent.="Sending To $name..........Sent<br />"; } ?> Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted December 8, 2007 Share Posted December 8, 2007 BTW I checked out your website and man it looks nice! Quote Link to comment Share on other sites More sharing options...
Zepo. Posted December 8, 2007 Author Share Posted December 8, 2007 Thank you! Well the two functions are in two different files....so i cant do it like that. Quote Link to comment Share on other sites More sharing options...
trq Posted December 9, 2007 Share Posted December 9, 2007 You have alot of code there that would be generating syntax warnings, and also absolutely no error handling. <?php if ($emailq = mysql_query("SELECT name,email FROM teams")) { if (mysql_num_rows($emailq)) { while(list($name,$email)=mysql_fetch_row($emailq)){ $email['toname'] =$name; $email['toemail'] =$email; $email['subject'] =$send['subject']; $email['fromname'] ={$_SESSION['rights']; $email['fromemail'] =$config['sitemail']; $email['replyname'] =$name; $email['replyemail'] =$email; $email['body'] =$send['body']; if (email($email)) { $sent.="Sending To $name..........Sent<br />"; } } } } Next, your email function should look like.... <?php function email($email){ return mail("{$email['toname']} <{$email['toemail']}>",$email['subject'],$email['body'], "From: {$email['fromname']} <{$email['fromemail']}>\nReply-To: {$email['replyname']} <{$email['replyemail']}>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion()); } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted December 9, 2007 Share Posted December 9, 2007 Also, ps. You are getting no errors becuas eyou obviously have error reporting switched off, or set too low. Otherwise all those syntax warnings I pointed out would show up. Make sure error reporting and display errors are on while you develop your scripts. Quote Link to comment Share on other sites More sharing options...
Zepo. Posted December 9, 2007 Author Share Posted December 9, 2007 My server is weird. I never get any php warnings, and instead of getting php errors, i get a 500 error, which had made it very hard to develop on this server. Quote Link to comment Share on other sites More sharing options...
Zepo. Posted December 9, 2007 Author Share Posted December 9, 2007 Also the code still doesnt work, you dont have the email function anywhere in your script... i put it in, and no luck... Quote Link to comment 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.