+ Reply to Thread
Results 1 to 4 of 4

 

Thread: Including a PHP include within a PHP include ??

  1. #1
    25 chars.? Need more spac

    Status
    Offline
    Join Date
    Aug 2003
    Location
    here
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts


    Currently I parse a perl database using a php include in the usual fashion...

    <? include ('http://www.url.com/database.pl?qry=QUERY'); ?>

    I also have a script day.php which will (strangely enough) display the day ....

    What I would like to be able to do is to create an include simlar to above, but replacing QUERY with the output of day.php - however even using absolute paths I still can't get it to work ... and may just scream until I'm sick (and I can...)

    Would someone please enlighten me as to how I should be doing this??

    Cheers!
    Duncan

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If your day.php echos the day to the browser then that is what it will still do when included. What you need to do is edit day.php so instead of echoing the result it saves it to a variable (if it isn't already in one) then use that variable in the second include.

    Assuming day.php assigns the day to $day then your code would look like

    <?
    include ('day.php');
    include ("http://www.url.com/database.pl?qry=$day");
    ?>

    Note: the second include must use " rather than ' to evaluate $day, also included php code is only parsed if the included file is local to the calling script i.e. accessed via a local path rather than a remote (http://) one.

    Hope this helps.

  3. #3
    25 chars.? Need more spac

    Status
    Offline
    Join Date
    Aug 2003
    Location
    here
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Rich
    If your day.php echos the day to the browser then that is what it will still do when included. What you need to do is edit day.php so instead of echoing the result it saves it to a variable (if it isn't already in one) then use that variable in the second include.
    D'oh! Call me Mr Dim and beat me about with a wet haddock..

    Cheers Rich, I make no excuses for my temporary lack of any common sense...

    Duncan

  4. #4
    Super Member

    Status
    Offline
    Join Date
    Sep 2003
    Location
    Manchester
    Posts
    1,066
    Thanks
    2
    Thanked 2 Times in 2 Posts
    madstock,

    sorry, not got the time today to think this through properly but take a look at the eval function. that may help as well.

    john

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Anyone anygood with xml, php, mysql and Affiliate Window
    By AnnonnyMouse in forum Affiliate Marketing Lounge
    Replies: 1
    Last Post: 23-09-04, 12:00 PM
  2. Php Include
    By scifind in forum Programming
    Replies: 5
    Last Post: 14-08-03, 06:01 AM

Bookmarks

Posting Permissions

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

Content Relevant URLs by vBSEO 3.5.0 RC2