Forum Moderators: coopster

Message Too Old, No Replies

php errors

i didn't change a thing, now i have 4 warnings. why?

         

ikbenhet1

4:54 pm on Jul 19, 2003 (gmt 0)

10+ Year Member



I had this piece of php that worked, i didn't change a thing. Now i got all these errors:

warning: Temporary failure in name resolution
warning: Bad file descriptor
warning: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
warning: Bad file descriptor

can this have happened because while it was uploading (a whole diffrent part of the site) i accidently went to another page? (not in ftp, but ensim)

How can i solve this? Is this solvable?

hakre

5:00 pm on Jul 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi ikbenhet1,

checkout in which line the name resolution occured. this is maybe a failure of a php function which was not able to resolve a network address.

if this is true, then your code has no failure, you just have to check the case, that name resolution might fail.

you can disable the warning messages by adding the '@' in front of any specific php command, like: @fopen(...), so this single command (file opening) won't output any error or warning while executing (i.e. file does not exists). only this single command, the rest in your script will.

ikbenhet1

5:11 pm on Jul 19, 2003 (gmt 0)

10+ Year Member



The 1st warning is from line 35. I get 2 warnings from line 35, but that line only has 1 command (file();).

34: $fils = "http://www.example.com/webgids/dochters.txt";
35: $linez = file($fils);

Here are the 1st 2 warnings in full:

Warning: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/virtual/site47/fst/var/www/html/webgids/index.php on line 35
Warning: file("http://www.example.com/webgids/dochters.txt") - Bad file descriptor in /home/virtual/site47/fst/var/www/html/webgids/index.php on line 35

<added> i downloaded the text file, deleted the file from the server, and uploaded it again. The error(s) are still is there. aarg.

Weird thing is, the homepage also uses file(); to get content, and that works just fine, no errors.

hakre

5:21 pm on Jul 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi ikbenhet1,

that's just what i assumed. now, you need to handle the case, that name resolution does not work first(!):

$linez = file($fils);
if ($linez) {
[your code here]
} else {
echo("failed to open '$fils'!");
}

then you can think about, why your domain is not able to be resolved... ;)

ikbenhet1

5:31 pm on Jul 19, 2003 (gmt 0)

10+ Year Member




I added your code. itstops the code after the error.

when i surf directly to this text file from the address bar: it shows all the content in my screen.

Is there something like chkdsk/scandisk for apache? maybe i can mail the host of the site and ask him to run that.

hakre

5:35 pm on Jul 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



a name resolution error is not a prob with the server or the file system there, it's a prob with your computer resolving the ip-adress of the domain name: 'www.example.com'.

please read the documentation of the fopen function and take a look at the details to open urls. check if your php is enabled to do so. try to find out, why php can't resolve the domain name, maybe checkout if php supplies a dns resolve function or similar.

ikbenhet1

5:41 pm on Jul 19, 2003 (gmt 0)

10+ Year Member



Ihe ip-adress of the domain is solved just fine, i can go to the homepage and it shows the content. The homepage uses file(); so it is defenitely enabled.

Please delete this thread.

ikbenhet1

6:27 pm on Jul 19, 2003 (gmt 0)

10+ Year Member



Sorry for the long thread, but i found the answer by myself, as there was not 1 site offering me the solution.

The sollution is change the domain with it's ip address.

wow, i did it all by myself.

<added> Thanks for your posts hakre, it made me look closer to the code. thanks.

hakre

8:00 pm on Jul 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



just wanted to remember you:
it's a prob with your computer resolving the ip-adress of the domain name: 'www.example.com'.

if you type in the ipadress instead of the domain name, name resolution is not necessary anymore, so it's a workaround (until the ip changes)... ;)

henry0

11:39 am on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hakre, are you saying that another machine pointing to the same URL will do fine?
I am trying to understand the main question which is why did it work and then did not any longer?
Henry

hakre

11:57 am on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



henry0:
Hakre, are you saying that another machine pointing to the same URL will do fine?

if the file exists on the server, every app and machine can request it, if
a) dns works (domain name resolution)
b) a connection between client and server is possible
c) both machines speak the same protocol
so: yes.

in this case, php had problems to resolve the ip address of the domain name. if php is not able to resolve it will never be able to even request the file.

since ikbenhet1 changed the domain name to the ip address, name resolution wasn't needed anymore and the script works again.

-hakre

henry0

12:06 pm on Jul 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks for the clarification

Henry