Page 1 of 1

Trouble Getting File

Posted: Thu Aug 16, 2007 4:40 pm
by Tomcat7194
Hello. I am trying to load the contents of http://radioserver.dnsalias.com/globalvar.csv into a string. However, the file_get_contents() function keeps giving me errors. Here is the code:

Code: Select all

<?php
$string = file_get_contents('http://radioserver.dnsalias.com/globalvar.csv', 'r');
print_r($string);
?>
Errors:
Warning: file_get_contents() [function.file-get-contents]: Circular redirect, aborting. in /home/tomsmith/public_html/diy-ha/access.php on line 2

Warning: file_get_contents(http://radioserver.dnsalias.com/globalvar.csv) [function.file-get-contents]: failed to open stream: Success in /home/tomsmith/public_html/diy-ha/access.php on line 2
Anything special I have to do here?
Thanks
Tom

Posted: Thu Aug 16, 2007 4:50 pm
by RobertGonzalez
Have you read the tip on the file_get_contents() function page? Do you have fopen_wrappers enabled?

Posted: Thu Aug 16, 2007 5:03 pm
by Tomcat7194
Thanks, I hadn't seen that. Since I'm on shared hosting, I'm not sure how readily I can access my php.ini file. Is there a way to tell whether fopen_wrappers is enabled?
Tom

Posted: Thu Aug 16, 2007 5:10 pm
by RobertGonzalez
Possibly running a phpinfo() or using ini_get() or ini_get_all().

Posted: Thu Aug 16, 2007 5:21 pm
by Tomcat7194
Here's the snippet from the php.ini dump:

Code: Select all

[allow_url_fopen] => Array ( [global_value] => 1 [local_value] => 1 [access] => 4 )
It's a booleen, right? So allow_url_fopen seems to be enabled. I should also point out that for some reason, this code:

Code: Select all

<?php
$string = file_get_contents('http://finance.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv', "r");
print_r($string);

?>
works just fine, even though it is essentially doing the same thing (loading an external CSV file). Could this suggest a problem with the external file, or something having to do with the DnsAlias service (it redirects to the dynamic IP address of a home server)?

Tom

Posted: Thu Aug 16, 2007 5:39 pm
by RobertGonzalez
Have you tried entering

Code: Select all

http://radioserver.dnsalias.com/globalvar.csv
in a browser to see what happens when the file is called?

Posted: Thu Aug 16, 2007 5:47 pm
by RobertGonzalez
I think it is on the server you are trying to contact. I can hit my site and google with no problem, but I am getting redirect errors when I try any part of the domain you are trying to hit.

Posted: Thu Aug 16, 2007 5:48 pm
by Tomcat7194
I get this:

http://www.diy-ha.com/acsv.GIF

Try http://68.36.62.91:80
That's the server's ip, without the redirection service (DynDNS aka DNSalias)

Tom

Posted: Thu Aug 16, 2007 6:11 pm
by RobertGonzalez
Are you testing these at all? I am simply running them from my server. The server whose IP address you gave is doing something weird with the stream request. Calling it by IP or domain name results in the same redirection error.