Parse error in code

Thread Solved

Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Parse error in code

 
0
  #1
Jul 10th, 2006
ok im new to PHP and sortof need to learn the basics for my job and i got the oreily PHP 5 book and in some of the examples i keep getting a parse error. here is an example [php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
//Print a greeting if the form was submitted
if ($_POST['user']) {
print "Hello, ";
//Print what was submitted in the form parameter called user
print $_POST['user'];
print "!";
}
else {
//otherwise, print the form
print <<<_HTML_
<form method="post" action="$SERVER[PHP_SELF]">
Your Name: <input type="text" name="user">
<br/>
<input type="submit" value="Say Hello">
</form>
_HTML_;
}
?>
</body>
</html>[/php]
and it says there is a parse error on the line with the </html>. I cant seem to figure what is wrong it is exactly like the book's example.
Last edited by mikeandike22; Jul 10th, 2006 at 10:33 pm.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Parse error in code

 
0
  #2
Jul 10th, 2006
I fixed the problem here is the updated code if you would like to compare

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <title>Untitled Document</title>
  6. </head>
  7. <body>
  8. <?php
  9. //Print a greeting if the form was submitted
  10. if ($_POST['user']) {
  11. print 'Hello, ';
  12. //Print what was submitted in the form parameter called user
  13. print $_POST['user'];
  14. print "!";
  15. }
  16. else {
  17. //otherwise, print the form
  18. print <<<_HTML_
  19. <form method="post" action="$SERVER[PHP_SELF]">
  20. Your Name: <input type="text" name="user">
  21. <br/>
  22. <input type="submit" value="Say Hello">
  23. </form>
  24. _HTML_;
  25. }
  26. ?>
  27. </body>
  28. </html>

i think it was the double quotes instead of the single in 'hello, '
Last edited by mikeandike22; Jul 10th, 2006 at 10:41 pm.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1
Reputation: gcardella is an unknown quantity at this point 
Solved Threads: 1
gcardella gcardella is offline Offline
Newbie Poster

Re: Parse error in code

 
0
  #3
Apr 18th, 2008
I had the exact same problem from the same book! The solution was to replace the double-quotes with single-quotes. Thanks!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC