Image

Imagefunnel101 wrote in Imagephp 😡frustrated

If/else only doing the If part

[EDIT: OMG I'M A MORON! Ignore all this! I wasn't uploading the test file, but saving it onto my computer!]

Right. So, I have some new snazzy php done for sugarthecat.com . The page loads. That's great, right? The problem is the php is not doing what it's supposed to be doing, and I am completely stumped as to why. Here's what the php is supposed to be doing:

If the variable t is set as something, it's supposed to be displaying a second menu. If the variable t is set to a specific something (sk is the test case), it's supposed to be adding special CSS to the page. And if the variable t is set to nothing, no CSS or second menu should be added.

What's happening is the CSS and second menu are displaying no matter what. And the php looks good to me, so I have no idea why. Here's the link to the page: http://www.sugarthecat.com/test.php . $t is not set at all on this page. You can see the second menu (the one that starts with "Previous Comic") and the background color is different than the original CSS file (to compare, see here: http://www.sugarthecat.com ).

[EDIT: I am having difficulty posting the php on here. Basically, I have if ($t=="sk"), then two variables ($h2 and $css) are set and $css is echoed to be included in the head html. Then, I have some HTML; then if (empty($t)), the $thisPage data gets displayed in the blue banner and nothing else happens; else $h2 gets displayed below the blue banner and then the second menu. Any suggestions?]

[EDIT 2:
<?php 

if ($t==="sk")
{
$h2 = "Snowcrash and Kosette: Love that Spans Time";
$css = <<<CSS

    body    {
        background-color: #8ea2bb;
        color: #000000;
        }
    
    ul.menu {
        background-color: #596b2f;
        }
        
    ul.menu li {
        background-color: #c1bab0;
        margin: 2px;
        display: inline;
        }
        
    ul.menu a:hover {
        border: 0px;
    }
    
CSS;

echo <<<HTML
<style type="text/css">
{$css}
</style>
HTML;
}
?>

</head>
<body>


<div id="top">
<IMG SRC="/Pics/s1.JPG" class="sugar">
<h1>Sugar the cat.com<I>ic</I></h1>
<ul class="top">
<li><A HREF="/Comics/about.html">About/Cast</A></li>
<li><A HREF="/Comics/archives.html">Archives</A></li>
<li><A HREF="/phpBB2/index.php">Forums</A></li>
<li><A HREF="/links.html">Links</A></li>
<li><A HREF="http://www.sugarthecat.com/phpBB2/viewforum.php?f=4">News Updates</A></li>
</ul>
<h1 class="small"><I>presents...</i></h1>

<?php
if (empty($t)) {
echo "<h1>{$thisPage}</h1>";
echo "</div>";}
else {
echo "</div>";
echo "<h1>{$h2}</h1>";

echo "<div id=\"menubar1\"><div id=\"menu3\" class=\"menu\"><A HREF=\"/Comics/";

$p=$n-1;

if ($p<=163)
echo "$p.html\">";
else
echo "$p.php\">"; 

echo "<-Previous Comic</A></div>";

echo "<div id=\"menu4\" class=\"menu\"><A HREF=\"/Comics/";

$n=$n+1;
$f="../Comics/{$n}.php";

if (file_exists($f))
echo "$n.php\">";
else
echo "..\index.php\">";

echo "Next Comic-></A></div>";

echo "<div id=\"menu1\" class=\"menu\"><A HREF=\"";
 
  if ($thisPage=="Index")
    echo "\"index.php\">";
    else
    echo "\"/Comics/$n.php\">";
 
echo "Newest Comic->|</A></ul></div>";
 
echo "<div id=\"menu2\" class=\"menu\"><A HREF=\"/Comics/archives.html\">Archives</A></div>";
echo "<div id=\"menu5\" class=\"menu\"><A HREF=\"http://www.sugarthecat.com/phpBB2/viewforum.php?f=4\">News Updates</A></div>";

echo "</div>";
}
?>


Can also be seen at http://www.sugarthecat.com/headertest.txt . ]

[EDIT 3: Also, should point out that this php is from an included file.]

[EDIT 4:
<?php $n="164"; 
$thisPage="Test"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head><title>Sugar the Cat.Comic: The Lives of our Three Spoiled Housecats</title>

<link rel="stylesheet" type="text/css" href="http://www.sugarthecat.com/default.css" />

<?php include ("headertest.php"); ?>

<TABLE>
<TR valign="top"><TD><img src="/Comics/164a.jpg" width="400" height="300" /></TD>
<TD><IMG SRC="/Comics/164b.jpg" width="400" height="300"></TD>
</TR>
<TR valign="top"><TD><img src="/Comics/164c.jpg" width="400" height="300" /></TD>
<TD><IMG SRC="/Comics/164d.jpg" width="400" height="300"></TD>
</TR>
<TR valign="top"><TD><img src="/Comics/164e.jpg" width="400" height="300" /></TD>
<TD><IMG SRC="/Comics/164f.jpg" width="400" height="300"></TD>
</TR></TABLE>


<?php include ("footer.php") ?>


<HR>
<small><I><B>Updated 11/11/2008.</B> This site was designed by <A HREF="http://www.funnelswebdesign.com" target="new">Funnel's Web Design</A>. All comics and artwork are &copy; Rob Harrison 2005-2008. You can <a href="/phpBB2/index.php">contact us via the forums</a> if you have any questions or comments.</I></small>
<HR>
<CENTER>
<script type="text/javascript"><!--
google_ad_client = "pub-1319153222862788";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
google_color_border = "B4D0DC";
google_color_bg = "ECF8FF";
google_color_link = "0000CC";
google_color_url = "008000";
google_color_text = "6F6F6F";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</CENTER>
<HR>

</body>
</html>
]