[thelist] php add email to a mysql db

Rich Gray richardgray at onetel.co.uk
Tue Aug 13 10:04:00 CDT 2002


You forgot the echo mysql_error() ... and you don't seem to have selected
the database ...

Try something like this...

$link = mysql_connect("$dbhost","$dbuser","$dbpass") or die("Can't
connect");

if (mysql_select_db("mydatabase",$link)) {

	$sql = "SELECT email FROM mailinglux WHERE  email='$email'";
	$result=mysql_query($sql);
         	if (mysql_num_rows($result) > 0)
             		echo "<center><h3>You are already in our system</h3>";
        	else {
		if(!EmailOK($email)) {
			echo "The email address you submitted is not valid.";
			exit;
		}
		mysql_query("insert into mailinglux values('$email')");
	}
}
else {
	echo "Can't select the database";
	exit;
}

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


this 'Parse error: parse error, unexpected T_VARIABLE ' is displayed when I
put
this
mysql_error() in and when its out this

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

is displayed

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);
         if ($num > 0)
             echo "<center><h3>You are already in our system</h3>";
        else {

mysql_error()

$sql = "INSERT INTO mailinglux(email) VALUES
('$name')";


if(!EmailOK($email)) {

echo "The email address you submitted is not valid.";

exit;
}

mysql_db_query($dbname, "insert into mailinglux values('','$email')");
}


Thank you

Andrew





---
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