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

andy
  • 97
  • 2
  • 8
  • use like this `echo "

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

    ";`
    – Muhammad Zeeshan Jun 28 '11 at 14:11
  • Did you try to put *both* at the end, in the right order? – Felix Kling Jun 28 '11 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 Jun 28 '11 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: http://php.net/heredoc – Marc B Jun 28 '11 at 14:27
  • @Marc B: Single and double quote strings are multiline as well. – hakre Jun 28 '11 at 14:31
  • @hakre: Yes, they can be, but you have to escape any embedded quotes. A HEREDOC requires no escaping at all, unless you want to embed a literal `{` and/or `$`. – Marc B Jun 28 '11 at 14:34
  • @Marc B: That's what NOWDOC then is for. However that specific HTML does not contain any quotes, so that's why I would not suggest HEREDOC in the first place. It does work however. – hakre Jun 28 '11 at 14:37
  • A single here-/now-doc is far more efficient and easier to read than multiline echoes, regardless of variable/quoting/escaping requirements. But best would be to drop out of PHP mode and let any decent editor colorize everything as HTML anyways. – Marc B Jun 28 '11 at 14:39

9 Answers9

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>";
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
0

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

Neil Knight
  • 47,437
  • 25
  • 129
  • 188
  • 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 Jun 28 '11 at 14:11
  • 1
    That's true, but wouldn't cause the code to break. It's a valid empty statement. – hughes Jun 28 '11 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.

ETWW-Dave
  • 732
  • 5
  • 8
0

You are not closing the quotes :

echo "

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

Tarek
  • 3,810
  • 3
  • 36
  • 62
  • i do that and i get another error – andy Jun 28 '11 at 14:25
  • what's the new error you are getting ? – Tarek Jun 28 '11 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 Jun 28 '11 at 15:26
  • do you have the file called header.php under the folder called include ? – Tarek Jun 28 '11 at 15:30
  • include ("includes/header.php"); header("Location:includindex.php"); is what I have – andy Jun 28 '11 at 15:52
  • you need to have a physical file called header.php here --> C:\wamp\www\include\header.php – Tarek Jun 28 '11 at 16:00
  • yes I do have that..I dont know what else it is doing.. I am trying all my sources... – andy Jun 28 '11 at 17:08
0

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

shanethehat
  • 15,460
  • 11
  • 57
  • 87
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.

AreYouSure
  • 732
  • 3
  • 9
  • 18
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();
}
JellyBelly
  • 2,451
  • 2
  • 21
  • 41
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();
}
?>
hakre
  • 193,403
  • 52
  • 435
  • 836
  • 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 Jun 28 '11 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 http://php.net/manual/en/function.include.php – hakre Jun 28 '11 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!

bpeterson76
  • 12,918
  • 5
  • 49
  • 82