| | |
Parse error in code
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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.
<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.
I fixed the problem here is the updated code if you would like to compare
i think it was the double quotes instead of the single in 'hello, '
PHP Syntax (Toggle Plain Text)
<!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>
i think it was the double quotes instead of the single in 'hello, '
Last edited by mikeandike22; Jul 10th, 2006 at 10:41 pm.
![]() |
Similar Threads
- Help. Parse error in PHP code (PHP)
- Parse error at last line of page's code (PHP)
- Parse Error in IF Statement (PHP)
- PHP Parse error: parse error, unexpected T_STRING (PHP)
- Need Help With Parse Error... (PHP)
- Parse error: (PHP)
- I need help with a parse error! (PHP)
Other Threads in the PHP Forum
- Previous Thread: data pass using submit button
- Next Thread: Parse error: syntax error, unexpected T_STRING in E:\Program Files\wamp\www\practice\
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql startup syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend






