PHP_SELF parse error
Posted by: scubajeff (---.bb.sky.com)
Date: October 21, 2009 09:35PM

I am learning PHP using SAMS Teach Yourself PHP book, and using the WampServer as a local host has been very helpful. However I've run into a problem with a script to add to a MYSQL database. I wasn't sure about posting the whole script, so I've only included the part that seems to be causing the problem - please let me know if I need to post or send the whole script.

The rest of the script conects to the server and database, and uses $_REQUEST to retrieve the values entered into the form. With the script below included within the php tags (as the in the book), I get a parse error on line 64 when the script is only 63 lines. I'd be grateful for any suggestions to what is going wrong.

function write_form(){
print <<<EOF
<form method="post" action="{$_SERVER['PHP_SELF']}">
//form details
<p><input type ="submit" value="submit"/></p>
</form>
FORM;
}


Thanks for your help
Jeff

Options: ReplyQuote
Re: PHP_SELF parse error
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: October 22, 2009 03:30PM

Its your HEREDOC statement that is causing the error. Your identifiers do not match
print <<<EOF
...
FORM;
FORM; should be EOF; instead.

Please read PHP Manual on HEREDOC syntax usage
[www.php.net]



Edited 1 time(s). Last edit at 10/22/2009 03:30PM by c2dan.

Options: ReplyQuote
Re: PHP_SELF parse error
Posted by: scubajeff (---.bb.sky.com)
Date: October 24, 2009 12:01PM

c2dan
Thank you for your help. I thought that might be the problem, but hadn't encountered the HEREDOC statement before to be able to work out what was wrong. The script is now working.
Thanks again
Jeff

Options: ReplyQuote


Sorry, only registered users may post in this forum.