Jump to content


Photo

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE


  • Please log in to reply
1 reply to this topic

#1 dovetail

dovetail
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 02 June 2006 - 04:41 AM

Hi, Could someone please look at this code and tell me why I get the following error?:

----------
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
---------


<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR...l1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />

<title>RSVP</title>

</head>

<body>

<?php

if (empty($_GET['name']) || !isset($_GET['attendance']))
echo "<p>You must enter your name and specify whether
you will attend! Click your browser's Back button to
return to the RSVP form.</p>";
else if ($_GET['attendance']=="yes"
&& !is_numeric($_GET['guests']))
echo "<p>Please specify the number
of guests who will accompany you! Click your
browser's Back button to return to the RSVP form.</p>;
else {
if ($_GET['attendance']=="yes") {
$YesFile="attending.txt";
if (file_put_contents($YesFile, addslashes($_GET['name'])
. ", " . $_GET['guests'] . "\n", FILE_APPEND))
echo "<p>Thanks for RSVPing! Were looking forward to seeing you!</p>";
else
echo "<p>Cannot save to the $YesFile file.</p>";
}
if ($_GET['attendance']=="no") { //This is line 28
$NoFile = "notattending.txt";
if (file_put_contents($NoFile, addslashes($_GET['name'])
. "\n", FILE_APPEND))
echo "<p>Thanks for RSVP'ing! Sorry you can't make it!</p>";
else
echo "<p>Cannot save to the $NoFile file.</p>";
}
}

?>

</body>

</html>

-----------------------------------

The html file that comes before it, if you need it, is...


<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR...l1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>

<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />

<title>RSVP</title>

</head>

<body>
<h1>Invitation</h1>
<p> You are cordially invited to attend the
celebration of the Andersons' 50th wedding
anniversary on October 15 at 8:00 p.m.</p>

<form action="SendRSVP.php" method="get">

<h2>RSVP</h2>
<p>Name &nbsp; <input type="text" name="name" size="50" /></p>
<p><input type="radio" name="attendance" value="yes" />I will attend &nbsp;</p>
<p><input type="radio" name="attendance" value="no" />I will NOT attend &nbsp;</p>
<p>Number of guests besides myself &nbsp;
<input type="text" name="guests" /></p>
<p><input type= "submit" value=" Send RSVP" /><input type="reset" />
</p></form>

<p><a href="attending.php">See Who's Attending</a><br />
<a href="notattending.php">See Who's Not Attending</a></p


</body>

</html>


I found my error! A quote mark is missing here:

"<p>Please specify the number
of guests who will accompany you! Click your
browser's Back button to return to the RSVP form.</p>;

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 June 2006 - 05:07 AM

browser's Back button to return to the RSVP form.</p>[!--coloro:red--][span style=\"color:red\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--];

please take the time to look at your own code. paying attention to the color changes in your code in your favorite php editor will clue you in on syntax errors. If you do not use an editor that turns your code different colors, get one.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users