Click to See Complete Forum and Search --> : What is wrong with this simple PHP code???
Mindman
06-28-2005, 03:02 PM
Can someone tell me what is wrong with this simple code, and why the heck I am getting a parse error???
if($_SERVER[SERVER_NAME] == "tntclan.local") {
print '<a href="/News/LatestNews.php"><img src="/IMAGES/TNTTrooper.jpg" border="0"></a><br><br>';
} else {
print <<< HERE
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="403" height="519">
<param name="movie" value="/IMAGES/INTRO.swf">
<param name="quality" value="high">
<embed src="/GLOBAL/Images/INTRO.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="403" height="519"></embed></object>
HERE;
}
peacefroggie
06-28-2005, 03:12 PM
edit: bad info
NogDog
06-28-2005, 03:30 PM
I'm not sure if this is the culprit, but it will return an error if your error reporting level is E_NOTICE or higher:
# this:
if($_SERVER[SERVER_NAME] == "tntclan.local")
# should be this:
if($_SERVER['SERVER_NAME'] == "tntclan.local")
For more info, go to http://www.php.net/manual/en/language.types.array.php and scroll/search down to the heading, "Why is $foo[bar] wrong?".
Mindman
06-28-2005, 03:34 PM
I'm not sure if this is the culprit, but it will return an error if your error reporting level is E_NOTICE or higher:
# this:
if($_SERVER[SERVER_NAME] == "tntclan.local")
# should be this:
if($_SERVER['SERVER_NAME'] == "tntclan.local")
For more info, go to http://www.php.net/manual/en/language.types.array.php and scroll/search down to the heading, "Why is $foo[bar] wrong?".
Tried that, didn't work... I should mention that the parse error is reported on this line:
print <<< HERE
BeachSide
06-28-2005, 03:53 PM
Everything between the HERE's is not php code you would probably do better with something like...
<?php
if($_SERVER['SERVER_NAME'] == "tntclan.local") {
print '<a href="/News/LatestNews.php"><img src="/IMAGES/TNTTrooper.jpg" border="0"></a><br><br>';
} else { ?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="403" height="519">
<param name="movie" value="/IMAGES/INTRO.swf">
<param name="quality" value="high">
<embed src="/GLOBAL/Images/INTRO.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="403" height="519"></embed></object>
<?php } ?>
NogDog
06-28-2005, 04:18 PM
Try removing the space between "<<<" and "HERE", perhaps? (I think I've always used it without a space, and that's how the examples look in the manual: http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc )
peacefroggie
06-28-2005, 04:20 PM
try closing the php tags after the HERE and reopen them for the }