473,507 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mailing list using MySQL / PHP

I have written a database which uses PHP to run through each ID in the
database and then generate a persons name and address to include into the
rest of the PHP to send an email out.

But as people have deleted or updated their details on this mailing list, I
now have "holes" in database. Ordinarily not a problem, but the code I've
written starts at ID 1 and after sending an email increments to the next
ID. But when it encounters a now vacant ID, it sends an error email to me
associated with that now blank ID row of data.

How can I change my code that will increment through all the results in
turn, but not give me these error emails when people have amended the
database?

Dariusz
Jul 17 '05 #1
2 2069
Why are you looping through the numbers?

Try just getting your excisting rows in sequence, ignoring the ID numbers
(you can read them if you need them, but shouldn't use them as criteria in
your SELECT statement)

Regards,

Michel

"Dariusz" <ng@lycaus.plusYOURSHIT.com> wrote in message
news:KH*********************@stones.force9.net...
I have written a database which uses PHP to run through each ID in the
database and then generate a persons name and address to include into the
rest of the PHP to send an email out.

But as people have deleted or updated their details on this mailing list, I now have "holes" in database. Ordinarily not a problem, but the code I've
written starts at ID 1 and after sending an email increments to the next
ID. But when it encounters a now vacant ID, it sends an error email to me
associated with that now blank ID row of data.

How can I change my code that will increment through all the results in
turn, but not give me these error emails when people have amended the
database?

Dariusz

Jul 17 '05 #2
Dariusz wrote:
I have written a database which uses PHP to run through each ID in the
database and then generate a persons name and address to include into the
rest of the PHP to send an email out.

But as people have deleted or updated their details on this mailing list, I
now have "holes" in database. Ordinarily not a problem, but the code I've
written starts at ID 1 and after sending an email increments to the next
ID. But when it encounters a now vacant ID, it sends an error email to me
associated with that now blank ID row of data.

How can I change my code that will increment through all the results in
turn, but not give me these error emails when people have amended the
database?

Dariusz


Instead of

$conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die();
loop() {
$sql = 'select c1, c2, c3 from table where id=' . $id;
$res = mysql_query($sql) or die();
$row = mysql_fetch_row($res);
mail($res[0], $res[1], $res[2]);
mysql_free_result($res) or die();
}
mysql_close() or die();

do

$conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die();
$sql = 'select c1, c2, c3 from table order by id';
$res = mysql_query($sql) or die();
while ($row = mysql_fetch_row($res)) {
mail($res[0], $res[1], $res[2]);
}
mysql_free_result($res) or die();
mysql_close() or die();

Disclaimer: both snippets were typed directly into the editor, and I
wasn't concentrating on making them right.

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1936
by: Dave Moore | last post by:
Hi All, Is it possible to implement a mailing list using PHP?. I know I could maintain a list of emails addresses in a db and send mail to them through my website, but how can I get true mailing...
0
6359
by: Brian van den Broek | last post by:
Hi all, There have been a few posts over the last month or so expressing a bit of exasperation with the "rising tide of newbie's". (Or, more accurately, the rising tide of questions from...
6
1793
by: IC | last post by:
Hi, I'm building a website and I want to include a mailing list. I just want a form where a user could enter their email address, so I could send them more information. I assume that the best...
3
1740
by: * Tong * | last post by:
or I have to be in some mlist in order to post? thanks -- Tong (remove underscore(s) to reply) *niX Power Tools Project: http://xpt.sourceforge.net/ - All free contribution & collection
29
3134
by: Mainlander | last post by:
An ISP I belong to uses Majordomo for their mailing list system. I'd like to encourage them to move to a system that uses a database, preferably psql which they already run on their server....
67
12426
by: Bob Powell | last post by:
To whom it may concern: I find the recent articles in various trade publications a little disturbing due to the lack of PostgrSQL mention. I continue to see articles about how IBM may be...
7
1330
by: David Garamond | last post by:
Would someone mind divulging the size (= number of members) of the @postgreql.org mailing lists (particularly pgsql-general and pgsql-hackers)? To tell you the truth, I've always got good responses...
4
2527
by: Andy M | last post by:
ALERT There is a person by the name of Mike Cox who's trying to turn this mailing list into a Big-8 newsgroup. Many of you know that this and most of the other postresql mailing lists are...
2
2096
by: divyac | last post by:
I have developed an address book using php and mysql.I have all the contacts list in a table with check boxes.Now that i want to create mailing labels for the checked contacts...i.e.,the arrangements...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.