Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function Problems

Status
Not open for further replies.

Quijian

ISP
Jul 9, 2004
32
US
This is the error I get:

Parse error: parse error, unexpected $ in /home/gardensm/public_html/create.php on line 232

Line 232 is the last line of the page. I know the problem has something to do with the function maincontent($id) because when I remove it, the site works fine.

The evil function:

Code:
function maincontent($id){
	switch($id){
		case "0":
			echo 'You do not have creator priveledges. Please contact you adminstrator for more information.';
			break;
		case "1":
			echo <<<DAN
				//HTML Start
				<table width="519" height="300" border="0" cellpadding="0" cellspacing="0">
				  <tr> 
					<td width="519" height="52"><div align="center">
						<table width="121" height="52" border="0" cellpadding="0" cellspacing="0">
						  <tr> 
							<td width="49" height="52"><img src="old/images/icons/create.jpg" width="49" height="52"></td>
							<td width="72"><font color="9999FF" size="6" face="Verdana, Arial, Helvetica, sans-serif">Create</font></td>
						  </tr>
						</table>
						<font face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
				  </tr>
				  <tr> 
					<td height="220"><div align="center"> 
						<table width="500" border="0" cellspacing="0" cellpadding="0">
						  <font color="9999FF" size="3" face="Verdana, Arial, Helvetica, sans-serif"><tr> 
							<td width="166" height="100"><div align="center">
								<p><a href="create.php?id=news"><img src="images/icons/news.jpg" width="49" height="52" border="0"></a></p>
								<p><a href="create.php?id=news">News</a></p>
							  </div></td>
							<td width="166" height="100"><div align="center">
								<p><a href="create.php?id=staff"><img src="images/icons/staff.jpg" width="49" height="52" border="0"></a></p>
								<p><a href="create.php?id=staff">Staff</a></p>
							  </div></td>
							<td width="166" height="100"><div align="center">
								<p>&nbsp;</p>
								</div></td>
						  </tr>
						  <tr> 
							<td width="166" height="100"><div align="center"></div></td>
							<td width="166" height="100"><div align="center">
								<p>&nbsp;</p>
								</div></td>
							<td width="166" height="100"><div align="center"></div></td>
						  </tr></font>
						</table>
						<font face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
				  </tr>
				</table>
				//HTML End
				DAN;
			break;
		case "2":
			echo <<<LAR
				//HTML Start
				<table width="519" height="300" border="0" cellpadding="0" cellspacing="0">
				  <tr> 
					<td width="519" height="52"><div align="center">
						<table width="121" height="52" border="0" cellpadding="0" cellspacing="0">
						  <tr> 
							<td width="49" height="52"><img src="old/images/icons/create.jpg" width="49" height="52"></td>
							<td width="72"><font color="9999FF" size="6" face="Verdana, Arial, Helvetica, sans-serif">Create</font></td>
						  </tr>
						</table>
						<font face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
				  </tr>
				  <tr> 
					<td height="220"><div align="center"> 
						<table width="500" border="0" cellspacing="0" cellpadding="0">
						  <font color="9999FF" size="3" face="Verdana, Arial, Helvetica, sans-serif"><tr> 
							<td width="166" height="100"><div align="center">
								<p><a href="create.php?id=news"><img src="images/icons/news.jpg" width="49" height="52" border="0"></a></p>
								<p><a href="create.php?id=news">News</a></p>
							  </div></td>
							<td width="166" height="100"><div align="center">
								<p><a href="create.php?id=staff"><img src="images/icons/staff.jpg" width="49" height="52" border="0"></a></p>
								<p><a href="create.php?id=staff">Staff</a></p>
							  </div></td>
							<td width="166" height="100"><div align="center">
								<p><a href="create.php?id=about"><img src="images/icons/about.jpg" width="49" height="52" border="0"></a></p>
								<p><a href="create.php?id=about">About</a></p>
							  </div></td>
						  </tr>
						  <tr> 
							<td width="166" height="100"><div align="center"></div></td>
							<td width="166" height="100"><div align="center">
								<p><a href="create.php?id=links"><img src="images/icons/links.jpg" width="49" height="52" border="0"></a></p>
								<p><a href="create.php?id=links">Links</a></p>
							  </div></td>
							<td width="166" height="100"><div align="center"></div></td>
						  </tr></font>
						</table>
						<font face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
				  </tr>
				</table>
				//HTML End
				LAR;
			break;
		default:
			echo 'error in the id variable';
	}//end switch
}//end function

Sorry it is a bit much...Any help will be much appreciated.
 
I figured it out...my heredoc syntax was messed up
 
You are right.
Heredoc requires the END delimiter to be at the beginning of a line - this explanation just for those reading the thread and wondering what was wrong.
Code:
[COLOR=red]WRONG[/color]
echo <<<DAN
  <html>
  <blah>....</blah>
  DAN;
[COLOR=green][b]RIGHT[/b][/color]
echo <<<DAN
  <html>
  <blah>....</blah>
[b]DAN;[/b]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top