Jump to content
MakeWebGames

Recommended Posts

Posted

Hi all. It's been an age since I last posted on here or did any PHP...and annoyingly, I've lost some of it and I need to rebuild my skills. "/

 

I'd usually be able to solve most problems, but I can't get round this $end issue. It's p*ssing me right off, and I've tried all that I can.

 

I'm getting this error: Parse error: syntax error, unexpected $end in /usr/home/****/domains/*******/public_html/header_test.php on line 117

Below is the code for this script (it's not too long):

<?php
class headers {function startheaders() {global $ud, $set;print <<<EOF<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" /><html xmlns = "http://www.w3.org/1999/xhtml" /><head /><meta http-equiv = "Content-Type" content = "text/html; charset = iso-8859-1" /><title />R.E.R | Home</title><style type = 'text/css' /></style></head><body><center><table width = '970' border = '0' cellpadding = '0' cellspacing = '0' class = 'bigtable' /><tr /><td />EOF;}function userdata($ud,$qs,$ts) {global $db, $uID, $set, $staffpage;print <<<OUT<img src = 'newbanner.jpg' alt = 'R.E.R Site' width = '100%' height = '100px' /> 
// <table width = '100%' border = '0' cellpadding = '0' cellspacing = '0' /><tr /><td width = '20%' valign = 'top' />
[b]Login Name:[/b] {$ud['login_name']}
[b]Num of questions answered:[/b] {$qs}
[b]Total Score:[/b] {$ts}<hr />OUT;}function menuarea() {include "mainmenu_test.php";global $ud,$c;print "</td> <td width = '2' /></td><td width = '80%' 
<center>[b]If you have any questions, please contain Ms O\'Hare at Lorraine.o\'[email protected][/b]";}function endpage() {global $db;print <<<OUT</center></td></tr></table></td></tr></table></center></body></html>OUT;}}?>

I really wish I could figure this out, but I've done all I can. Any help with this will be highly appreciated. :) Thank you.

Posted

Hello War_Hero,

When I put this code into my IDE and put each line of code onto it's own line, there were no syntax errors.

The use of heredoc (<<<EOT and EOT;) is tricky and probably is the source of the errors.

A line of code like this (from your code above) is invalid without line breaks:

print <<<OUT</center></td></tr></table></td></tr></table></center></body></html>OUT;

 

This code below is valid:

		print <<<OUT
</center></td></tr></table></td></tr></table></center></body></html>
OUT;

 

Here are some things to note about heredoc formatting:

 

		print <<<OUT // <---- nothing can come after this part of this line. not even a space
</center></td></tr></table></td></tr></table></center></body></html>
OUT;//<-------- nothing can come after this line either. heredoc must be ended on it's own line.
//^
//|
//|
// \----------  OUT; must start on a new line, with nothing before it on that new line (you could use EOT; or
//FFF; or any series of letters so long as it matches the series of letters that began the heredoc sequence)

 

Hope that helps.

Posted

Thank you very much. Removing the tabs before the OUT; solved my problem. :)

Does the same apply to EOF; or is it just OUT; EOT; etc?

Thanks again for the help. It's very much appreciated.

Posted
You're welcome.

It would apply to EOF. The letters used in heredoc identifiers don't matter, and the rules are the same for all.

Cheers

Thank you for you help. :) I'll make sure I remember that when using them again.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...