SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can no longer Include an external link

    Last week my host upgraded me from PHP version 3.0.19 to version 4.0.4pl1, at my request. Everything has been running great, except for one thing - I can no longer "include" external links.

    Specifically, I have a page that shows upcoming concert listings, thanks to itickets.com. However, now it gives me an error. To see it in action, go to http://www.christianguitar.ws/concerts/, and type in "Ginny Owens". It should show all of her concerts - instead, it shows an error.

    Warning: Failed opening 'http://www.itickets.com/partners/insertphp?brand=120&selectName=1&sw=ginny owens&lim=' for inclusion (include_path='') in /home/web/c/christianguitar.ws/htdocs/concerts/index.php on line 114

    I'm thinking that it's some sort of misconfiguration in my php.ini, but my host (of course) says that it's not. Also, the URL that it "failed" to open is always valid.

    Lastly, you can check out my PHP configuration at the following address:
    http://www.christianguitar.ws/boards/phpinfo.php

    Any help would be much appreciated. Thanks!

    Mickey

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If this has only happened since the upgrade it must be a problem with the host

    Sean

  3. #3
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using readfile() instead of include, include was never really meant to be used for including pages from other servers.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The configuration looks good to me, can tell us the code you're using?

  5. #5
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sean - I agree it is probably with the host. However, I need something specific to say. ("it's a problem with....")

    Karl - I tried that, and now I'm getting the following error:

    Warning: readfile("http://www.itickets.com/partners/insertphp?brand=120&selectName=1&sw=ginny owens&lim=") - Success in /home/web/c/christianguitar.ws/htdocs/concerts/index.php on line 114


    Mickey

  6. #6
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That line of code is simply:
    Code:
    <? if($brand>0) { include "http://www.itickets.com/partners/insertphp?brand=$brand&selectName=$selectName&sw=$sw&lim=$lim"; } ?>
    Where "brand" tells whether it's actually searching for an artist, or just displaying the search page.

    Mickey

  7. #7
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to urlencode() the url first.

  8. #8
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, but this worked fine with PHP version 3. Did something like that change between 3 and 4?

    Mickey

  9. #9
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Beats me, you should have been doing it in PHP3 too.

  10. #10
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, now I get a messier error.

    Code:
    Warning: Failed opening 'http%3A%2F%2Fwww.itickets.com%2Fpartners%2Finsertphp%3Fbrand%3D%24brand%26selectName%3D%24selectName%26sw%3D%24sw%26lim%3D%24lim' for inclusion (include_path='') in /home/web/c/christianguitar.ws/htdocs/concerts/index.php on line 117
    Any ideas?

    Mickey

  11. #11
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't use urlencode() on that url.


    Could be a bug in your version of PHP, have you searched the bug reports yet? Also unless your variables have weird characters in them then you don't need urlencode(). IN the bug reports on php.net it does mention something about include() and readfile() although the specific problem is not listed. I would coax them into putting a newer version on your server and see if that helps.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  12. #12
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah sorry, you just need to urlencode $sw (because of the space).

  13. #13
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah.. right my bad as anarchos said if there will be spaces or weird cahracters in a variable you'll need to encode() it, but just the variable not the whole url.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  14. #14
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a follow up to Karl's post. I just checked the manual and it says that using a remote file through HTTP in an include directive is OK and even gives examples.

    This is a weird one eh? But it sounds like the whitespace might be a problem. In this case the trick is to urlencode() the varialbes before placing them in the URL string: eg:

    $brand = urlencode($brand);

    etc...

  15. #15
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I said that three posts ago....

  16. #16
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...err, sorry Anarchos. I did not mean to speak over you. I did not read the thread well enough. I got distracted looking in the manual.

  17. #17
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all of the suggestions. Doing the urlencode() on the individual variables made sense, and made it look cleaner. However, the error was still the same. I did some research on PHP bugs, and found a few that were related to version 4.0.5, and I'm still on 4.0.4pl1, which shouldn't be affected.

    I'm still thinking that it's a PHP setup/config error, but I don't know what it could be. I've read a bit about the "URL fopen wrappers" needing to be enabled, but I haven't been able to find anything about that in my php.ini file, or in my phpinfo. Any ideas about that?

    Thanks!

    Mickey

  18. #18
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I checked that, it's the allow_url_fopen in your php.ini and it's already set correctly. Can you post the updated code?

  19. #19
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's been fixed! The problem (I guess) is that PHP4 is too smart. PHP3 just linked to that address, no problem. However, the address didn't point to a file - just a directory (and then it pulled up the index.php3 file). I guess PHP4 needs a specific file to point to, or it's a bug or something. When I changed it from:
    include("http://...../insertphp?brand=...
    to:
    include("http://.../insertphp/index.php3?brand=...
    it fixed it!

    Thanks to everyone for all of your help with this.

    Mickey


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
  •