0

I am getting this error that is reading

Parse error: parse error, unexpected '>' in C:\wamp\www\about.php on line 11

Here is my code:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name'])){;
header("Location:includeindex.php");
exit;
 }
 else{
TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>
echo "<p>I been married for 5 years but been with my husband for 11 years </p>
echo "<p>I am attending college for Computer Programming and Database Mangament      </p>
echo "<p>After I get done with this degree I am want to go back for Web Design </p>
echo "<p>since half my classes are web design now. I enjoy camping,bon fires and </p>
echo "<p>playing video games, hanging out with friends and family.</p>
Footer();
   }
 ?>

I have tried adding ; to the end and " to the end but the same thing pops up. Can someone sees what I am doing wrong.

Here is the error i get when i add "; to the end of those:

Warning: include(include/header.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\about.php on line 3

Warning: include() [function.include]: Failed opening 'include/header.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\about.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\about.php:3) in C:\wamp\www\about.php on line 5

8
  • use like this echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>"; Commented Jun 28, 2011 at 14:11
  • Did you try to put both at the end, in the right order? Commented Jun 28, 2011 at 14:13
  • You do not need to use echo to output larger chunks of HTML. Close the PHP, output the HTML and then open PHP again. See my answer below for an example.
    – hakre
    Commented Jun 28, 2011 at 14:23
  • As @hakre says, close the PHP. If you HAVE to do this while in PHP mode, at least use a HEREDOC, which is designed for multiline strings: php.net/heredoc
    – Marc B
    Commented Jun 28, 2011 at 14:27
  • @Marc B: Single and double quote strings are multiline as well.
    – hakre
    Commented Jun 28, 2011 at 14:31

9 Answers 9

5

You have:

echo "<p>playing video games, hanging out with friends and family.</p>

You need:

echo "<p>playing video games, hanging out with friends and family.</p>";
3
  • Or the echo " on each next line is redundant and only one "; is missing at the end of all output.
    – hakre
    Commented Jun 28, 2011 at 14:21
  • i do that fix and i get another error
    – andy
    Commented Jun 28, 2011 at 14:25
  • i already did all that but i get new errors.
    – andy
    Commented Jun 28, 2011 at 14:40
0

You need to add a quote "; to the end of your echo lines

2
  • While technically incorrect (looking), that's not an error - it only adds a blank statement as the first statement of the if block. Strange, but won't throw an error.
    – ETWW-Dave
    Commented Jun 28, 2011 at 14:11
  • 1
    That's true, but wouldn't cause the code to break. It's a valid empty statement.
    – hughes
    Commented Jun 28, 2011 at 14:12
0

You need a quote and a semicolon at the end of each echo line.

Generally speaking, any time you open a quote on a line in PHP, you'll also need to close it, and every line (with a few exceptions, such as flow-control statements, etc.) will need to be terminated by a semi-colon.

0

You are not closing the quotes :

echo "

Here is a little about me. I am a mother of twin girls who are 9 ";

7
  • i do that and i get another error
    – andy
    Commented Jun 28, 2011 at 14:25
  • what's the new error you are getting ?
    – Tarek
    Commented Jun 28, 2011 at 14:45
  • Warning: include(include/header.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\about.php on line 3 Warning: include() [function.include]: Failed opening 'include/header.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\about.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\about.php:3) in C:\wamp\www\about.php on line 5
    – andy
    Commented Jun 28, 2011 at 15:26
  • do you have the file called header.php under the folder called include ?
    – Tarek
    Commented Jun 28, 2011 at 15:30
  • include ("includes/header.php"); header("Location:includindex.php"); is what I have
    – andy
    Commented Jun 28, 2011 at 15:52
0

All of your echo lines need to close their speechmarks and finish with a semicolon.

0

try this:

session_start();
include_once ("include/header.php");
if (!isset($_SESSION['name'])) {
    header("Location:includeindex.php");
    exit;
}
else {
    TopNavigation("about Me -ECA236", "About Me", $_SESSION['name']);
    echo "<p>Here is a little about me. I am a mother of twin girls who are 9</p>";
    echo "<p>I been married for 5 years but been with my husband for 11 years</p>";
    echo "<p>I am attending college for Computer Programming and Database Mangament</p>";
    echo "<p>After I get done with this degree I am want to go back for Web Design</p>";
    echo "<p>since half my classes are web design now. I enjoy camping,bon fires and</p>";
    echo "<p>playing video games, hanging out with friends and family.</p>";
    Footer();
}
0

The syntax of your file is wrong. The following example should fix it, however, the message just means that part of your output is indeed code because you missed to properly use the " quotes around strings. Keep in mind that strings work over multiple lines as well, so this is probably easier to understand:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name']))
{
  header("Location:includeindex.php");
  exit;
} else {
  TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
  echo "
    <p>Here is a little about me. I am a mother of twin girls who are 9 </p>
    <p>I been married for 5 years but been with my husband for 11 years </p>
    <p>I am attending college for Computer Programming and Database Mangament      </p>
    <p>After I get done with this degree I am want to go back for Web Design </p>
    <p>since half my classes are web design now. I enjoy camping,bon fires and </p>
    <p>playing video games, hanging out with friends and family.</p>
    " # string ends here
    ;
  Footer();
}
?>

Or even better as this is PHP:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name']))
{
  header("Location:includeindex.php");
  exit;
} else {
  TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
  ?>
    <p>Here is a little about me. I am a mother of twin girls who are 9 </p>
    <p>I been married for 5 years but been with my husband for 11 years </p>
    <p>I am attending college for Computer Programming and Database Mangament</p>
    <p>After I get done with this degree I am want to go back for Web Design </p>
    <p>since half my classes are web design now. I enjoy camping,bon fires and </p>
    <p>playing video games, hanging out with friends and family.</p>
  <?php
  Footer();
}
?>
2
  • I am getting these errors now Warning: include(include/header.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\about.php on line 3 Warning: include() [function.include]: Failed opening 'include/header.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\about.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\about.php:3) in C:\wamp\www\about.php on line 6
    – andy
    Commented Jun 28, 2011 at 14:33
  • In which path is the file include/header.php? In case you wonder what include does and what the error message means, checkout php.net/manual/en/function.include.php
    – hakre
    Commented Jun 28, 2011 at 14:34
0

Like everyone else said, you need the quotes and semi colons. But that's also ignoring that there are less verbose (and less overhead) methods of doing this. For example, you could do all under one echo statement:

echo"
  <p>>Here is a little about me. I am a mother of twin girls who are 9</p>
  <p>I been married for 5 years but been with my husband for 11 years</p>
  <p>I am attending college for Computer Programming and Database Mangament</p>
";

Or, an alternative method is

$content = " <<<END
  <p>Here is a little about me. I am a mother of twin girls who are 9</p>
  <p>I been married for 5 years but been with my husband for 11 years</p>
  <p>I am attending college for Computer Programming and Database Mangament</p>
END;

echo $content;

The best possible solution, if you're going to be doing a ton of non-php, is just to close the PHP tag and do it with straight HTML where you don't have to worry about quotes and semicolons at all!

?>
  <p>Here is a little about me. I am a mother of twin girls who are 9</p>
  <p>I been married for 5 years but been with my husband for 11 years</p>
  <p>I am attending college for Computer Programming and Database Mangament</p>
<?php

My point is that I see a lot of <?php> and </php> repetition as well as a ton of echo repetition on SO examples. Does it work? Sure. But it's unnecessary. It slows you down, and creates more opportunities to screw up. And, it's just plain ugly! I don't want to debug it!

0

You are not closing any of the echo statements at all. The below should work:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name'])){
header("Location:includeindex.php");
exit;
 }
 else{
TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>";
echo "<p>I been married for 5 years but been with my husband for 11 years </p>";
echo "<p>I am attending college for Computer Programming and Database Mangament      </p>";
echo "<p>After I get done with this degree I am want to go back for Web Design </p>";
echo "<p>since half my classes are web design now. I enjoy camping,bon fires and </p>";
echo "<p>playing video games, hanging out with friends and family.</p>";
Footer();
   }
 ?>

I also see a semi-colon on Line 4 which I don't think is needed - Removed it above.

4
  • Still needs semicolons on all other lines. Commented Jun 28, 2011 at 14:12
  • If you mean the echo statements I realised after first posting and added these in after.
    – AreYouSure
    Commented Jun 28, 2011 at 14:13
  • Why the semicolon after the first if statement?
    – cypher
    Commented Jun 28, 2011 at 14:27
  • I stated that I didn't believe it was needed. I'll remove this from my answer though.
    – AreYouSure
    Commented Jun 28, 2011 at 15:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.