...

View Full Version : Problems with simple mailing list add



Boxwell
01-23-2008, 11:04 AM
Hello,

I'm really new to php and am looking to create a database from people adding their email address using a submit button. I'm getting the following error:


Parse error: syntax error, unexpected T_VARIABLE in /usr/local/psa/home/vhosts/******.com/httpdocs/emailadd.php on line 15

(I've starred out the webaddress)

Here is the HTML form code:


<html>
<body>

<form action="emailadd.php" method="post">
Email: <input type="text" name="emailadd" />
<input type="submit" />
</form>

</body>
</html>


and this is the php code:


<?php

$user="******";
$password="********";
$database="MailingList";
$connection = mysql_connect('localhost',$user,$password);
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db($database)


$emailadd = $_POST['emailadd'];

if($emailadd != ""){
$query="INSERT INTO 'EmailAddresses'('Email') VALUES ($emailadd)";
}

mysql_close($connection);

?>


I'm a bit stuck, if anyone can help me it will be greatly appreciated.

Thanks

Graeme

PappaJohn
01-23-2008, 05:27 PM
Missing semi-colon:


mysql_select_db($database);

Inigoesdr
01-23-2008, 05:43 PM
You should put single-quotes around $emailadd in your query, and pass it through mysql_real_escape_string() as well.

Boxwell
01-23-2008, 07:33 PM
Thanks for all your help. Its now working. Smiley faces all round!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum