A question to those who know a lot about php

Discussion in 'PHP' started by Jen-, Sep 23, 2006.

  1. #1
    Hello, is there a problem with php calling url's in an array if they are not in the same directory? I can call pages just fine in the same directory but I am trying to call actual web site url's. So I put them in an array instead and it still doesn't work?

    I looked at all the php manuals and their url instructions don't make sense for what I am trying to do.

    Anyone know if there is a special command that needs to go in the code to make url's elswhere work, instead of your own web pages? Url's like something.com etc. etc. Thank you very much!
     
    Jen-, Sep 23, 2006 IP
  2. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    I don't fully understand your problem. What exactly you mean by calling them? To include, grab or link to them?
     
    Evoleto, Sep 23, 2006 IP
  3. pcoptimized

    pcoptimized Peon

    Messages:
    193
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Same here, could you please explain in more details? You can include, grab or link to them, but what do you mean by "call"? Can you give an example?
     
    pcoptimized, Sep 23, 2006 IP
  4. GuitarFix

    GuitarFix Peon

    Messages:
    37
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Jen-
    maybe it's not be able cause your configuration file doesn't allow to parse urls?
     
    GuitarFix, Sep 23, 2006 IP
  5. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What does parse url's mean, you could be onto something, but maybe not, not getting any parse errors. Regarding getting, I have an array with web site url's in them. This is used to include each url in the array by day.

    $date = date('d');
    include($content[$date]);

    but its not working. It reads the array but says it can't open the file.
     
    Jen-, Sep 24, 2006 IP
  6. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    give us $content array content
    Also if you are trying to include file from different servers - make sure you have whole path with http:// at beginning.
    P.s. It's bad idea to make including from other server, security bad idea
     
    intoex, Sep 24, 2006 IP
  7. harsh789

    harsh789 Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #7
    PHP on Window prior to 4.3.0 do not support accessing remote files via include() function. Also see the allow_url_fopen configuration option.
     
    harsh789, Sep 24, 2006 IP
  8. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I think php prior to 4.3.0 is a history :)
     
    intoex, Sep 24, 2006 IP
  9. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ok but then this doesn't
     
    Jen-, Sep 24, 2006 IP
  10. harsh789

    harsh789 Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #10
    If you are including pages from the same server

    include("/path-to-pages/".$content[$date]);
    Code (markup):
    If you are including pages from other server

    include("http://www.remote-server.com/".$content[$date]);
    Code (markup):
     
    harsh789, Sep 24, 2006 IP
  11. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Hey Harsh, hoping you had it. All it did was put the two addresses together..
    Failed opening 'http://www.remote-server.com/http://www.photomatt.net
    Know what I did wrong? The good news is it grabbed the right url, just didn't open it.

    I'm thinking I need to use fopen instead of include, to open url's not url's on same server. But when I do, I get no error messages but also no url's.

    Gosh didn't think calling a url using php would be so hard.
     
    Jen-, Sep 24, 2006 IP
  12. discoverclips

    discoverclips Peon

    Messages:
    491
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I don't think you should be using include() for calls outside your local server.
    try file_get_contents for that...
     
    discoverclips, Sep 24, 2006 IP
  13. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    <?php
    $filename =
    "http://www.website.com";
    fopen($filename, "r") || die ("Could not open file");

    ?>

    Nope get contents didn't work either, this is what I am using to test trying to call a basic url, hope someone knows.
     
    Jen-, Sep 24, 2006 IP
  14. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #14
    I don't know exactly what do you want to accomplish, but here is my suggested code:

    
    $date = date('d');
    $text = file_get_contents( "http://www.website.com/" . $content[$date]);
    
    // Now do something with $text, display it for example: echo $text;
    
    Code (markup):
     
    Evoleto, Sep 24, 2006 IP
  15. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    You did it!!! Can't believe it. Wow, that one took awhile for me. I'll have to see if all I needed was echo on the other part. Thank you so very, very, much--your a php genius Evoleto!
     
    Jen-, Sep 24, 2006 IP