[thelist] php add email to a mysql db
Andrew Maynes
andrew at uk-webdeveloper.co.uk
Tue Aug 13 11:44:26 CDT 2002
excellent thank you
Andrew
-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Ben Phillips
Sent: Tuesday, August 13, 2002 03:34
To: thelist at lists.evolt.org
Subject: RE: [thelist] php add email to a mysql db
there are a few syntax errors in the code. i've altered them below:
> this is the code:
>
> include("settings.inc");
>
> mysql_connect("$dbhost","$dbuser","$dbpass");
>
> $sql = "SELECT email FROM mailinglux WHERE
> email='$email'";
> $result=mysql_query($sql);
> $num=mysql_numrows($result);
mysql_numrows() should be mysql_num_rows().
> if ($num > 0)
when using if statements, surround all blocks in curly brackets. so:
if ($num > 0) {
// do stuff when $num > 0
echo "...";
} else {
// do stuff when $num isn't > 0
mysql_error()
...
}
it's a lot easier to read, for you and for others, and will also make
spotting errors easier.
benji.
inchima.com
--
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
More information about the thelist
mailing list