0
votes

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

9
use like this echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>";Muhammad Zeeshan
Did you try to put both at the end, in the right order?Felix Kling
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
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/heredocMarc B
@Marc B: Single and double quote strings are multiline as well.hakre

9 Answers

5
votes

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>";
0
votes

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

0
votes

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
votes

You are not closing the quotes :

echo "

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

0
votes

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

0
votes

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
votes

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();
}
?>
0
votes

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
votes

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.