[thelist] php add email to a mysql db

Nan Smith nansmith at heritageconcord.org
Tue Aug 13 09:34:01 CDT 2002


oh, sorry. In my haste, I put in a backwards bracket. The bracket in
front of the else should face the other way.
Nan

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Andrew Maynes
Sent: Tuesday, August 13, 2002 9:38 AM
To: thelist at lists.evolt.org
Subject: RE: [thelist] php add email to a mysql db


this produces this

Parse error: parse error, unexpected T_ELSE in

Andrew

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Nan Smith
Sent: Tuesday, August 13, 2002 02:13
To: thelist at lists.evolt.org
Subject: RE: [thelist] php add email to a mysql db


Why don't you try:

$sql = "SELECT email FROM TableName WHERE
          email='$email'";
         $result=mysql_query($sql);
         if ($result){

             echo "<center><h3>You are already in our system</h3>";
{
        else {

$sql = "INSERT INTO TableName(name,email,phone,company,message) VALUES
('$name','$email','$phone','$company','$message')";
}
If there is a match, then there is a result, and the number of rows does
not matter.

Nan

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Andrew Maynes
Sent: Tuesday, August 13, 2002 8:47 AM
To: thelist at lists.evolt.org
Subject: RE: [thelist] php add email to a mysql db


this is really useful too, however it is kicking out this

Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource

any ideas?

Thank you

Andrew



-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Gary Bland
Sent: Tuesday, August 13, 2002 12:23
To: thelist at lists.evolt.org
Subject: Re: [thelist] php add email to a mysql db


Andrew Maynes wrote:
> Hi all
>
> glad we are back online, is it just me or is everyoner getting 2-3
mails of
the
> same post?
>
> anyway here is the question, I have a form that I would like to get the
email
> inserted into a MySQL db is this possible?  I mean possible to use the
existing
> form elements and adding a tick box sent me a weekly newsletter?
>
> Thank you
>
> Andrew
> ---

Yes but you really need to check to see if the email address is already
there so you don't end up with someone putting the same email address in
several times. Here is one Of mine just adjust the INSERT to fit your
need.

$sql = "SELECT email FROM TableName WHERE
          email='$email'";
         $result=mysql_query($sql);
         $num=mysql_numrows($result);
         if ($num > 0)
             echo "<center><h3>You are already in our system</h3>";
        else {

$sql = "INSERT INTO TableName(name,email,phone,company,message) VALUES
('$name','$email','$phone','$company','$message')";



--
Gary Bland
StarChaser Web Architecture
http://star-chaser.com
Building Tomorrow's World Today

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list