473,666 Members | 2,175 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 2084
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.plus YOURSHIT.com> wrote in message
news:KH******** *************@s tones.force9.ne t...
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(D B_HOST, DB_USER, DB_PASS) or die();
loop() {
$sql = 'select c1, c2, c3 from table where id=' . $id;
$res = mysql_query($sq l) or die();
$row = mysql_fetch_row ($res);
mail($res[0], $res[1], $res[2]);
mysql_free_resu lt($res) or die();
}
mysql_close() or die();

do

$conn = mysql_connect(D B_HOST, DB_USER, DB_PASS) or die();
$sql = 'select c1, c2, c3 from table order by id';
$res = mysql_query($sq l) or die();
while ($row = mysql_fetch_row ($res)) {
mail($res[0], $res[1], $res[2]);
}
mysql_free_resu lt($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
1953
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 list behaviour where emails are sent to a particular address (like mailinglist@mydomain.com) and then distributed to all of the email addresses?. Ta, Dave
0
6370
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 newbie's not trying to follow ESR's advice.) A month or so ago (in a thread found here: http://tinyurl.com/5bj8j), I suggested that it might help the situation if there were a python.org wiki page that amounted to a "Welcome to the Python community;...
6
1802
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 way to do this is with ASP. Right now, I'm learning ASP by testing pages using Abyss web sever with Active HTML. I have XP Home, so I can't use IIS. Here are my questions: 1. Is ASP the best way to create a mailing list
3
1752
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
3166
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. Anything out there in Php?
67
12502
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 considering MYSQL for development an open_source web database. Why isn't PostgreSQL being considered or talked about by major industry giants? As a DBA I know that Postgres is far superior to MYSQL but if the industry directs it's energies towards...
7
1342
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 from this list. Apparently most other question posts do too. There seems to be always someone knowledgeable to answer questions, which is very very nice :-) -- dave
4
2539
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 already gated to Google Groups and a small number of private news servers. If Mike Cox succeeds, this list will be available as a newsgroup on a great many more ISPs and NSPs, which could be a good or a bad thing. For one, e-mail addresses on this
2
2110
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 of addresses should be modified in such a way that there should be 5 addresses in a row of the table...I have done some coding but just dont know how to retrieve the checked contacts..Also..i have some problem in creating labels in which some...
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1772
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.