Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    26
    Thanks
    6
    Thanked 0 Times in 0 Posts

    fopen() headache

    I am trying to run the following code:

    PHP Code:
    <?php

    $url 
    "http://mydomain.com/stats/tracker.php?page=TESTENTRY"// I have removed the domain for demo purposes but the domain exists, is resolved etc etc.

    $handle fopen ($url"r");
    $test fgets($handle);
    fclose($handle);

    ?>
    When I do I get the error:

    Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/user4873/public_html/test.php on line 5
    allow_url_fopen is set to On in php.ini. Any ideas on why this is happening? The same script works on a different server and loads fine with no errors.

    PLEASE someone help with this one. Thank you!
    Atlanta Web Design <- They do good work.

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    A quick google search (http://www.google.com/search?q=Warni...ient=firefox-a) yields this from the php.net manual:

    If you're having problems with fopen("url...") but you can run 'host url' in a shell window and get the correct lookup, here's why...

    This has had me banging my head against it all day - finally I found the answer buried in the bug reports, but figured it should really be more prominent!

    The problem happens when you're on an ADSL line with DHCP (like our office)... When the ADSL modem renews the DHCP lease, you can also switch DNS servers, which confuses apache (and hence PHP) - meaning that you can't look up hosts from within PHP, even though you *can* from the commandline.... The short-term solution is to restart apache.

    You'll get "php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in ..." messages as symptoms. Restart apache, and they're gone :-)

    Simon
    I find it very helpful to simply copy / paste the warning message into google to find results to problems like this.

  • The Following 2 Users Say Thank You to bcarl314 For This Useful Post:

    oesxyl (05-20-2008), pixencom (05-20-2008)

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    just in case echo the url, could be a typo somewhere in http:// part, and check the php version,

    if you don't find anything try to compare the configuration of both servers, with what you said until now it must work.

    regards

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    26
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bcarl314 View Post
    A quick google search (http://www.google.com/search?q=Warni...ient=firefox-a) yields this from the php.net manual:



    I find it very helpful to simply copy / paste the warning message into google to find results to problems like this.
    Thanks for the replies. I actually did google search this, I guess I did look hard enough. All what I read was make sure that its set to "On" in php.ini. I am on a shared server right now, what do I tell my webhost to get them to fix this?

    Also just wanted to point out (dont know if it makes a difference) my error states:

    php_network_getaddresses: getaddrinfo failed: Name or service not known
    php_network_getaddresses: getaddrinfo failed: Temporary failure in name
    Like I said, dont know if its the same thing.
    Atlanta Web Design <- They do good work.

  • #5
    New to the CF scene
    Join Date
    May 2008
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    why do you use file_get_contents() instead?

  • #6
    New Coder
    Join Date
    Apr 2008
    Posts
    26
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I get the same error with that:

    Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/user4873/public_html/test.php on line 5
    Atlanta Web Design <- They do good work.

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    That error usually means that your server has a DNS configuration error or similar problem. Notify your host and see what they can do about it.

  • #8
    New Coder
    Join Date
    Apr 2008
    Posts
    26
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thank you for your replies. I submitted a ticket on hostgator and linked them here and they took care of the problem. No more errors! Thanks again.
    Atlanta Web Design <- They do good work.


  •  

    Posting Permissions

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