Getting an error but can't find the problem
Posted: Thu Mar 06, 2008 7:42 am
Hi
I am getting this error when i load my php page
Parse error: syntax error, unexpected $end in /homepages/12/d235019564/htdocs/phptest/ssf.php on line 78
I have looked through the document and read it back against the example from the book and i can't see the error. Can anyone else see what is wrong?
Cheers
RichG
I am getting this error when i load my php page
Parse error: syntax error, unexpected $end in /homepages/12/d235019564/htdocs/phptest/ssf.php on line 78
I have looked through the document and read it back against the example from the book and i can't see the error. Can anyone else see what is wrong?
Code: Select all
<?php
if ($_POST['submit'] == 'submit')
{
if (!$_POST['email'] || $_POST['email'] == "" || strlen($_POST['email'] >30))
{
$message = '<p>There was a problem. Did you enter an email address?</p>';
}
else
{
// Open connection to database
$connect = mysql_connect('xxxx', 'xxxx', 'xxxx');
if( empty($connect))
{
die ("Error. Could not connect to server");
}
if( !mysql_select_db('xxxx'))
{
die ("Error. Could not connect to specified database");
}
//Insert email address
$as_email = addslashes($_POST['email']);
$tr_email = trim($as_email);
$query = "INSERT INTO mailinglist (id, email, source) VALUES (NULL, '$tr_email', 'www.example.com')";
$result = mysql_query($query);
if (mysql_affected_rows() == 1)
{
$message = '<p>Your information has been recorded</p>';
$noform_var = 1;
}
else
{
error_log (mysql_error());
$message = '<p>Something went wrong with your signup attempt.</p>';
}
}
//Show the form in every case except succesful submission
if (!$noform_var)
{
$thisfile = $_SERVER['PHP_SELF'];
$message .= <<< EOMSG
<p>Enter your email address and we will send you our weekly newsletter.</p>
<FORM METHOD="post" ACTION="$thisfile">
<INPUT TYPE="text" SIZE="25" NAME="email">
<BR><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="submit">
</FORM>
EOMSG;
}
}
?>
<html>
<head>
<STYLE TYPE="text/css">
<!--
BODY. P {color: black; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px}
H1 {color:black; font-family:Arial, Helvetica, sans-serif; font-size:12px}
-->
</STYLE>
</head>
<body>
<table border="0" cellpadding="10" width="100%">
<tr>
<td bgcolor="#f0f8ff" align="center" valign="top" width="17%"></td>
<td bgcolor="#FFFFFF" align="left" valign="top" width="83%"><H1>Newsletter Sign-up form</H1>
<?php
echo $message;
?>
</td>
</tr>
</table>
</body>
</html>RichG