Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to debug these warnings 1

Status
Not open for further replies.

praywin

Programmer
Feb 6, 2003
31
IN
Hi, I've been getting this error intermitently. It goes away with a reload but every couple of days I see this warning. Since it is not reproducible easily I haven't been able to track it down.

Has anyone see such type of warnings? Any ideas how to go about debugging this?

Warning: readfile(): php_network_getaddresses: getaddrinfo failed:
 
Can you show us a code fragment? I suspect your trying to open a file via HTTP
 
I agree with ingresman on both counts. That you should show us what your code is doing and that you're trying to use readfile() with a URL.

The problem, if you are using readfile() with a URL is that PHP was not able to resolve the address in the URL. As DNS is a distributed database, problems in many places on the internet can caus DN resolution failures.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I admit guys, my question doesn't have much details.

Its a pretty simple code fragment

readfile(/home/some/dir/abc.php)

which I use to include a header in on a page. The file is in the proper place (its on the same server) and the script works well and doesn't have errors etc. (its been in use for a long time).

Its just that it just fails sometimes and issues the warning, goes away with a couple of reloads and you don't see it for some time. The problem is a lot of users see it and I'd love if I could fix it soon. To make matters worse I can't reproduce it every time.

Maybe its just some problem on the ISP side and doesn't have anything to do with the php script. I just want to know if anyone has seen such problem before as I'm kind of at loss how to go about resolving it.
 
If the file is actually on the same server, then don't use the " part. If it isn't, but the info is (mostly) static, copy it locally. That's an expensive call to include headers every time.
 
in any case it is a DNS problem: sometimes your server can not resolve the name of "
If has a static IP, you have 2 choices:
#1 - the faster - use readfile(
#2 if for some reasn you can not use #1 ( on could be some VirtualHost(s) ), you can add an entry in /etc/hosts file, about .


HTH


___
____
 
Just out of interest why are you trying to do it via HTTP ?
 
Thanks guys, I guess I can avoid the error if I read it using the absolute path on the server than going through HTTP.
 
It's just a good idea to always use filesystem paths when opening a file on your own server:[ul][li]as you have found, it's more realiable, as your script is not dependent on as many outside systems to operate[/li][li]it uses fewer server resources, as the communication does not have to go through the local web server[/li][li]It's faster, as your script does not have to wait on DNS to operate[/li][li]since PHP's filesystem functions, when used with filesystem paths, is not constrainted by a web site's document root, your script can access files that may not be available on a web site.[/li][/ul]

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top