Jump to content

[SOLVED] simple php code displaying white page


aebstract

Recommended Posts

Eh, I don't see a problem with it and I have isolated it down to this chunk of code, so maybe someone can see what is causing it. I know there are probably shorter ways to do this same code, but for now just help getting the error out if you don't mind. Thanks!

 

<?php


if ($page == home) {
echo '<div id="nav1"><a href="/print/"><img src="/printx.png" border="0" /></a></div>
<div id="nav2"><a href="/identity/"><img src="/identityxx.png" border="0" /></a></div>
<div id="nav3"><a href="/web/"><img src="/webx.png" border="0" /></a></div>
<div id="nav4"><a href="/home/"><img src="/home.png" border="0" /></a></div>';
} elseif ($page == web) {
echo '<div id="nav1"><a href="/print/"><img src="/printx.png" border="0" /></a></div>
<div id="nav2"><a href="/identity/"><img src="/identityx.png" border="0" /></a></div>
<div id="nav3"><a href="/web/"><img src="/web.png" border="0" /></a></div>
<div id="nav4"><a href="/home/"><img src="/homex.png" border="0" /></a></div>';
} elseif ($page == identity) {
echo '<div id="nav1"><a href="/print/"><img src="/printxx.png" border="0" /></a></div>
<div id="nav2"><a href="/identity/"><img src="/identity.png" border="0" /></a></div>
<div id="nav3"><a href="/web/"><img src="/webxx.png" border="0" /></a></div>
<div id="nav4"><a href="/home/"><img src="/homexx.png" border="0" /></a></div>';
} elseif ($page == print) {
echo '<div id="nav1"><a href="/print/"><img src="/print.png" border="0" /></a></div>
<div id="nav2"><a href="/identity/"><img src="/identityxxx.png" border="0" /></a></div>
<div id="nav3"><a href="/web/"><img src="/webxxx.png" border="0" /></a></div>
<div id="nav4"><a href="/home/"><img src="/homexx.png" border="0" /></a></div>';
} else {
echo '<div id="nav1"><a href="/print/"><img src="/printx.png" border="0" /></a></div>
<div id="nav2"><a href="/identity/"><img src="/identityxx.png" border="0" /></a></div>
<div id="nav3"><a href="/web/"><img src="/webx.png" border="0" /></a></div>
<div id="nav4"><a href="/home/"><img src="/home.png" border="0" /></a></div>';
}
?>

Two things:

 

1.)$page is undefined - if it comes from the URL, take it out of the $_GET array, if its posted, take it out of the $_POST array

2.)You need to quote your strings in your if statement, like

if($page == 'home'){

 

 

The reason for the blank screen is that your script produces a parse error (for the reasons given above) and you have php set up not to display errors - therefore you don't even see the error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.