...

View Full Version : echoing an includedscript/switch



zoobie
07-31-2008, 07:29 AM
I echo different pages according to login status.
I'm trying to echo an include ("inc/header.php") which displays the image of the month via a switch inside header.php
Instead, the echo just shows the text (below) instead of the image


include ("inc/header.php");


Inside inc/header.php is


<?php
switch(date('n')) {
case 1: echo '<img src="img/header/red.gif">'; break;
case 2: echo '<img src="img/header/purp.gif">'; break;
case 3: echo '<img src="img/header/green.gif">'; break;
case 4: echo '<img src="img/header/blue.gif">'; break;
etc...
}

?>


It looks like it's trying to echo an echo...which isn't working
I've also used the full path in the echo...no go

I think I need serious help...:eek:

Thanks

ssonawa
07-31-2008, 10:47 AM
Why not to take a variable, assign image value to it, then echo.

zoobie
07-31-2008, 07:34 PM
see below

zoobie
08-01-2008, 08:52 AM
How would I include the switch at the top then call on it within the echo?
Maybe that's the ticket
Nothing's worked so far...it may be a server setup problem
Thanks

zoobie
08-01-2008, 07:21 PM
I just remembered some clever coding I received over at PHP Builders a few years ago. I've simply closed my argument, inserted my whole page, then continued the argument and redirect if not logged in...which is what I was trying to do to begin with....


if($userdata['session_logged_in'])
{
?>
<html></html>
<?php
}
else
{
header ("Location: here.php");
}
?>


You can also stop and start the echo...


<?php
echo '<html><body>';
include ("inc/menu.php");
echo '</body></html>';
?>


Worked like a charm :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum