Log in

View Full Version : Parse Error I can't even find!



MrRSMan
01-07-2008, 07:31 PM
I have the following code;


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Rune Voyage</title>
<link rel="stylesheet" type="text/css" href="styles/main.css">
</head>
<body>

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];



if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<span class="style3">Unfortunately, the email address you entered does not seem to be valid.</span>\n";
$badinput = "<span class="style3">Please go back and try again.</span>\n";
echo $badinput;
die ("");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<span class="style3">Sorry, but we were unable to process the form. Please go back and ensure all fields are completed.</span>\n";
die ("");
}


$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " \n
Subject: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("runevoyage@googlemail.com", $subject, $message, $from);

?>

<p align="left" class="style3">
Thank you <?php echo $visitor ?> for contacting us.</p>
<p align="left" class="style3">
Withing the next few minutes you should receive an email from us confirming your contact.<br>
If you chose to be contacted by us, you will receive your reply to the email address you gave you us- <?php echo $visitormail ?>.</p>

<p align="left" class="style3">
<a href="index.htm">Continue to Rune Voyage home page.</a></p>

</body>
</html>


However, when it runs, I get;


Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/mrrsman/public_html/sendeail.php on line 28

(Sendeail.php is the name of the page).

I can't find an error...let along know how to fix it!

Please help!

MrRSMan.

thetestingsite
01-07-2008, 07:34 PM
The error comes from not escaping quotes on the following lines:



echo "<span class="style3">Unfortunately, the email address you entered does not seem to be valid.</span>\n";
$badinput = "<span class="style3">Please go back and try again.</span>\n";


You should either use single quotes, escape them with a slash ( \" ), or break out of php before sending HTML to the browser.



echo '<span class="style3">Unfortunately, the email address you entered does not seem to be valid.</span>';
echo "\n";

$badinput = "<span class=\"style3\">Please go back and try again.</span>\n";


Hope this helps.

MrRSMan
01-07-2008, 07:36 PM
Thank you very much!

I'm fairly new to PHP you see...:)

Twey
01-07-2008, 08:44 PM
Don't output HTML from PHP: it's inefficient and gets ugly fast. Break out of PHP parsing mode, or use a template engine like Smarty (http://smarty.php.net/).