Trouble Getting File

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tomcat7194
Forum Commoner
Posts: 48
Joined: Mon Jul 31, 2006 1:34 pm

Trouble Getting File

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Have you read the tip on the file_get_contents() function page? Do you have fopen_wrappers enabled?
Tomcat7194
Forum Commoner
Posts: 48
Joined: Mon Jul 31, 2006 1:34 pm

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Possibly running a phpinfo() or using ini_get() or ini_get_all().
Tomcat7194
Forum Commoner
Posts: 48
Joined: Mon Jul 31, 2006 1:34 pm

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Tomcat7194
Forum Commoner
Posts: 48
Joined: Mon Jul 31, 2006 1:34 pm

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply