Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts

    echoing an includedscript/switch

    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
    PHP Code:
    include ("inc/header.php"); 
    Inside inc/header.php is
    PHP Code:
    <?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...

    Thanks
    Last edited by zoobie; 07-31-2008 at 07:47 AM. Reason: update
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #2
    New Coder
    Join Date
    Jul 2008
    Location
    India
    Posts
    39
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Why not to take a variable, assign image value to it, then echo.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    see below
    Last edited by zoobie; 08-01-2008 at 07:41 PM. Reason: update
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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 or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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....
    Code:
    if($userdata['session_logged_in'])
    {
    ?>
    <html></html>
    <?php
    }
    else
    {
    header ("Location: here.php");
    }
    ?>
    You can also stop and start the echo...
    Code:
    <?php 
    echo '<html><body>'; 
    include ("inc/menu.php"); 
    echo '</body></html>'; 
    ?>
    Worked like a charm
    Last edited by zoobie; 08-01-2008 at 07:40 PM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •