Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2000
    Location
    Lowlands
    Posts
    717

    * including a php file gives me an error. Not when include() through HTTP

    Hi all!

    When I try to include a php file like this:
    <?
    require "file.php";
    ?>
    I get this error:
    Fatal error: Failed opening required file.php'
    (include_path='.:/usr/share/php') in /home/test/public_html/file.php on line 1


    But when I do it like this:
    <?
    require "http://mydomain.com/file.php";
    ?>
    it works!

    Why is this? I can't figure out why because on some clients it does work both ways.
    What is configured wrong here?

    Thank you,
    Domenico

  2. #2
    Join Date
    Jan 2002
    Location
    Ohio
    Posts
    3,131
    <?
    require "file.php";
    ?>
    Not that I'm, a php expert, but try this...

    PHP Code:
    <? 
    require ('file.php'); 
    ?>
    Well... it works fine for me....

    hope this helps a little....
    Glioblastoma Multiforme (GBM) Brain Cancer Awareness. May is Brain Cancer awareness month. Gray Matters!
    Incurable, 6-18 months prognosis, survivors longer than 3 years less than 1% chance.
    Don't like what I say? Ignore me.

  3. #3
    Join Date
    Mar 2002
    Posts
    1,003
    Check your php.ini file and make sure that "include_path" has no entry next to it.

  4. #4
    Join Date
    Dec 2000
    Location
    Lowlands
    Posts
    717
    Nope, I allready tried that one
    It gives me the same error.

    Anyone else?

  5. #5
    Join Date
    Dec 2000
    Location
    Lowlands
    Posts
    717
    Before there was .:/usr/share/php behind it but I removed it and restarted apache and now the error is:

    Fatal error: Failed opening required 'd_projects.php?show=10' (include_path='') in /home/test/public_html/file.php on line 2


  6. #6
    um... are you sure the file exists in the same dir as the script??
    The Php Support Desk
    http://www.phpsupportdesk.com
    Custom programming - kunal @ e-phoria.com
    http://www.pingzine.com - Ping!Zine. the FREE, FRESH and EXCITING Web Hosting Magazine...

  7. #7
    Join Date
    Dec 2000
    Location
    Lowlands
    Posts
    717
    Yes, it's in the same dir.

  8. #8
    Join Date
    Dec 2000
    Location
    Lowlands
    Posts
    717
    Let me rephrase my problem because I forgot to mention something.

    What I want to use but doesn't work is:
    <?
    require "file.php?show=10";
    ?>

    This works now:
    <?
    require "file.php";
    ?>

    So why is this then?

  9. #9
    Hi,

    You cannot include/require a file with any parameters passed to it directly as php looks for a file called "file.php?show=10" rather than just "file.php".

    If show is not already defined in your script change it to the following:

    <?
    $show=10;
    require "file.php";
    ?>

    And it will be included correctly as file.php can see the variable as it is already defined in the script, note this only works for direct includes and not using includes via http:// for which you should use:

    <?
    require "http://mydomain.com/file.php?show=10";
    ?>

    HTH

  10. #10
    Join Date
    Dec 2000
    Location
    Lowlands
    Posts
    717
    Thanks for telling Jamesl!

    I thought of this but didn't tried it yet, stupid me

    Anyways, this is what the manual says:
    - To include the top downloaders, sorted by number of reviews and rating (greatest to least), insert this where you would like the top downloaders to appear: <? require "d_top.php?show=xx"; ?> Replace "xx" with the number of top "downloaders" to display.

    hehehe, someone has to go back to school then

  11. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

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