Thread: include(header)

    #1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    15
    I use lots of variables on my site, these are 'carried on' by putting...
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <? include("/path/to/inc/link.php"); ?>
    [/code]
    ...after each href eg:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <a href="/news/<? include("/path/to/inc/link.php"); ?>">
    [/code]

    Does anyone know how to do this with header("Location...

    I've tried putting a . after the last " and then including the file but this doesn't work.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    header("Location: <A HREF="http://www.url.com/".include("/path/to/inc/link.php"));" TARGET=_blank>http://www.url.com/".include("/path/to/inc/link.php"));</A>
    [/code]

    Any ideas?

    Thanks

    ------------------
    Girish Gupta
    MusicGoesOn.com

    [This message has been edited by girish_gupta (edited October 22, 2000).]
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    header() doesn't like the use of the concat operator. Create a temp variable first:

    $location= "http://www.url.com/".include("/path/to/inc/link.php");

    header("Location: $location");
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    15
    This doesn't seem to work:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $location="http://www.musicgoeson.com/".include("/path/to/inc/link.php");
    header("Location: $location");
    [/code]

    It gives me an error 404. And when there is a query string. It goes to the correct URL but adds 1 to the variable, eg http://www.musicgoeson.com/?var=g - http://www.musicgoeson.com/?var=g1

    Any ideas why this is happening?

    Thanks

    ------------------
    Girish Gupta
    MusicGoesOn.com

    [This message has been edited by girish_gupta (edited October 22, 2000).]
  6. #4
  7. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    Maybe I'm missing something...

    When you call a header all you want is a path. include() calls the whole *contents* of a file. If you have a variable such as $thelink defined in "link.php" that you want to use, you just include the file separately from your Header: function, then concatenate variables.

    I would think you are looking for:

    <?
    include("/path/to/inc/link.php");
    // $thelink is defined inside link.php
    $location="http://www.musicgoeson.com/".$thelink;
    header("Location: $location");

    Or am I misunderstanding exactly what you are trying to do? It seems, though, that using an include AS the variable is a mistake, or a waste of resources. Using an include (or setting an auto-prepend) to DEFINE global variables is another thing.

IMN logo majestic logo threadwatch logo seochat tools logo