Does anyone have a simple php script that will pull emails from an mysql table and put it into an email list or seperated by commas, or a command to pull it from the db and seperating it with comma's to use for email
Thanks
Mikedo a query from the table to get the list of emails, then use the implode function:
$result = mysql_query("SELECT email FROM contact_table");
for ($i = 0; $i < sizeof($result)); $i++)
$emails[$i] = $result[$i]['email'];
$email_list = implode(", ", $emails);
info on:
php mysql_query function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.mysql-query.php">http://uk.php.net/manual/en/function.mysql-query.php</a><!-- m -->)
php implode function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.implode.php">http://uk.php.net/manual/en/function.implode.php</a><!-- m -->)
HKthanks I will try it outOriginally posted by Horus_Kol
do a query from the table to get the list of emails, then use the implode function:
$result = mysql_query("SELECT email FROM contact_table");
for ($i = 0; $i < sizeof($result)); $i++)
$emails[$i] = $result[$i]['email'];
$email_list = implode(", ", $emails);
info on:
php mysql_query function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.mysql-query.php">http://uk.php.net/manual/en/function.mysql-query.php</a><!-- m -->)
php implode function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.implode.php">http://uk.php.net/manual/en/function.implode.php</a><!-- m -->)
HK
that won't work Horus, $results is a resource ID and not an array. and $result[$i]['email']; is invalid.
you want this
$result = mysql_query("SELECT email FROM contact_table");
while ($row = mysql_fetch_array($result)){
$emails[] = $row['email'];
}
$email_list = implode(", ", $emails);
that is but one way as there are a lot of ways to do it.
but curious as to why get all thsoe out to put in commas. are you using a mailing list or something?yes scoutt that is what I want to do acutally is pull the email lists out of my db and exclude anyone with @aol.com
emails, is this something that is possible
Mikewhile ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
there is one way.i tried this
<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php")
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
?>
and I am getting this error:
Parse error: parse error, unexpected T_VARIABLE in /home/rantman/public_html/maillist.php on line 17
any ideasyou forgot a semi-colon after this
include("mainfile.php")
also change $row['email'] to $row['user_email']thanks that worked and now I am getting a result but no emails
<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php");
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
echo "$row";
?>
i added the
echo "$row";
to show my emails and I am getting a blank screen
and if i do
echo "$result";
i get
Resource id #9
as my result, how do i get the emails in a comma seperated field so I can use them for an email messagewhere is #row coming from? you never set that variable.
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
print_r($emails);
?>
all of your email are in an array. they are in $emails<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php");
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
print_r($emails);
?>
check it out at <!-- m --><a class="postlink" href="http://www.sportsrant.com/maillist.php">http://www.sportsrant.com/maillist.php</a><!-- m -->
and look at the results
i dont get it, and just when I thought that I was getting somewhere with phpyou forgot to change this line
$emails[] = $row['email'];
to read
$emails[] = $row['user_email'];i am such an idiot man, sorryokay man it works now but the format is not seperated by commas: it looks like this
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> [2] => <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> [3] => <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
when i want it to look like this:
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> because you need to run it through an "implode" function, to generate a string:
$email_list = implode(", ", $emails);I thought you wanted a simple email script? not a mass email script. php is not good for this as it can get a timeout error.
in order to send email to everybody you can't do that with the commas, it has to be in a loop. once you got all the emails in an array to loop through them and send to each one.where do i put that in the script? right before the echo??put what? the implode or the loopbasically what I want to do is to get an email list from my database excluding the @aol.com members and cut and paste it into an email list that I can create in outlook. that is why i want them seperated by commma's
Does that make since
and I want to know where the implode goes ??
I only have 1034 members, Why would it time out
MikeI thought you wanted to send the email in php. so if you want to cop y the emails then fine it won't have any problems with that.
<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php");
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
$email_list = implode(", ", $emails);
echo $email_list;
?>thank you sir that worked like a charm and exatly like i want it to
I really appreciate it
hey do you know where I can find someone to undertake a huge php script/task for me. I mean money is invloved
Mikeno I am affraid not. you might try the aquiring skills forum.
Thanks
Mikedo a query from the table to get the list of emails, then use the implode function:
$result = mysql_query("SELECT email FROM contact_table");
for ($i = 0; $i < sizeof($result)); $i++)
$emails[$i] = $result[$i]['email'];
$email_list = implode(", ", $emails);
info on:
php mysql_query function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.mysql-query.php">http://uk.php.net/manual/en/function.mysql-query.php</a><!-- m -->)
php implode function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.implode.php">http://uk.php.net/manual/en/function.implode.php</a><!-- m -->)
HKthanks I will try it outOriginally posted by Horus_Kol
do a query from the table to get the list of emails, then use the implode function:
$result = mysql_query("SELECT email FROM contact_table");
for ($i = 0; $i < sizeof($result)); $i++)
$emails[$i] = $result[$i]['email'];
$email_list = implode(", ", $emails);
info on:
php mysql_query function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.mysql-query.php">http://uk.php.net/manual/en/function.mysql-query.php</a><!-- m -->)
php implode function (<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.implode.php">http://uk.php.net/manual/en/function.implode.php</a><!-- m -->)
HK
that won't work Horus, $results is a resource ID and not an array. and $result[$i]['email']; is invalid.
you want this
$result = mysql_query("SELECT email FROM contact_table");
while ($row = mysql_fetch_array($result)){
$emails[] = $row['email'];
}
$email_list = implode(", ", $emails);
that is but one way as there are a lot of ways to do it.
but curious as to why get all thsoe out to put in commas. are you using a mailing list or something?yes scoutt that is what I want to do acutally is pull the email lists out of my db and exclude anyone with @aol.com
emails, is this something that is possible
Mikewhile ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
there is one way.i tried this
<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php")
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
?>
and I am getting this error:
Parse error: parse error, unexpected T_VARIABLE in /home/rantman/public_html/maillist.php on line 17
any ideasyou forgot a semi-colon after this
include("mainfile.php")
also change $row['email'] to $row['user_email']thanks that worked and now I am getting a result but no emails
<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php");
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
echo "$row";
?>
i added the
echo "$row";
to show my emails and I am getting a blank screen
and if i do
echo "$result";
i get
Resource id #9
as my result, how do i get the emails in a comma seperated field so I can use them for an email messagewhere is #row coming from? you never set that variable.
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
print_r($emails);
?>
all of your email are in an array. they are in $emails<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php");
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
print_r($emails);
?>
check it out at <!-- m --><a class="postlink" href="http://www.sportsrant.com/maillist.php">http://www.sportsrant.com/maillist.php</a><!-- m -->
and look at the results
i dont get it, and just when I thought that I was getting somewhere with phpyou forgot to change this line
$emails[] = $row['email'];
to read
$emails[] = $row['user_email'];i am such an idiot man, sorryokay man it works now but the format is not seperated by commas: it looks like this
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> [2] => <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> [3] => <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
when i want it to look like this:
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> because you need to run it through an "implode" function, to generate a string:
$email_list = implode(", ", $emails);I thought you wanted a simple email script? not a mass email script. php is not good for this as it can get a timeout error.
in order to send email to everybody you can't do that with the commas, it has to be in a loop. once you got all the emails in an array to loop through them and send to each one.where do i put that in the script? right before the echo??put what? the implode or the loopbasically what I want to do is to get an email list from my database excluding the @aol.com members and cut and paste it into an email list that I can create in outlook. that is why i want them seperated by commma's
Does that make since
and I want to know where the implode goes ??
I only have 1034 members, Why would it time out
MikeI thought you wanted to send the email in php. so if you want to cop y the emails then fine it won't have any problems with that.
<?php
######################################################
# File to set the theme selection for ALL users
# After you used this file, you can safely delete it.
######################################################
# -= WARNING: PLEASE READ =-
#
# NOTE: This file uses config.php to retrieve needed
# variables values. So, to do the upgrade PLEASE copy
# this file in your server root directory and execute
# it from your browser.
######################################################
include("mainfile.php");
$result = mysql_query("SELECT user_email FROM nuke_users");
while ($row = mysql_fetch_array($result)){
$domain = explode("@",$row['user_email']);
if ($domain[1] != "aol.com"){
$emails[] = $row['email'];
}
}
$email_list = implode(", ", $emails);
echo $email_list;
?>thank you sir that worked like a charm and exatly like i want it to
I really appreciate it
hey do you know where I can find someone to undertake a huge php script/task for me. I mean money is invloved
Mikeno I am affraid not. you might try the aquiring skills forum.