LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-17-2006, 11:50 AM   #1
Ultrus
Member
 
Registered: Jan 2006
Posts: 50

Rep: Reputation: 15
Question Apache/PHP - loading file from another server


Hello,
I'm super happy that I got Apache, PHP, MySQL, and phpMyAdmin working wonderfully on Suse 10. I'm facing a challenge however that I could use some advise on.

I'm loading an xml file into my php script. It works great when going through my hosting company (based on linux). Here is what a portion of it looks like:

PHP Code:
$units="f";

$location="80218";

$weatherfile "http://xml.weather.yahoo.com/forecastrss?p=$location&u=$units";
if (!(
$fp = @fopen($file"r"))) { //Remove the "@" to see error messages.
        
$theResponse "I can't seem to connect to the weather source right now. Is the internet on?";

    } else {
        
$theResponse "The file loaded just great.";
}
echo(
$theResponse); 
When I run this script on my machine, I get this error:

Warning: fopen(http://xml.weather.yahoo.com/forecastrss?p=80401&u=f): failed to open stream: HTTP request failed! in /home/ultrus/public_html/aiml/programE/src/plugins/cs_weather.php on line 72
RESPONSE: I can't seem to connect to the weather source right now. Is the internet on?


Is there some type of Apache or PHP security setting or firewall setting that is preventing me from loading file sources from the internet? How do I fix it? Thanks for the help.
 
Old 04-17-2006, 12:00 PM   #2
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
Well... one thing I see right off the bat is that $weatherfile is not the same as $file.
 
Old 04-17-2006, 02:39 PM   #3
Ultrus
Member
 
Registered: Jan 2006
Posts: 50

Original Poster
Rep: Reputation: 15
Ah yes. Sorry about that. I tried to abbriviate the code as $file was once part of a function that it is now not a part of. Here is the code with your correction:

PHP Code:
$units="f";

$location="80218";

$weatherfile "http://xml.weather.yahoo.com/forecastrss?p=$location&u=$units";
if (!(
$fp = @fopen($weatherfile"r"))) { //Remove the "@" to see error messages.
        
$theResponse "I can't seem to connect to the weather source right now. Is the internet on?";

    } else {
        
$theResponse "The file loaded just great.";
}
echo(
$theResponse); 
Thanks much
 
Old 04-18-2006, 08:21 AM   #4
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
Interesting. I just tried it myself and it worked just fine. I just took your code and tested it myself with the following fragment:

Quote:
<?PHP
$units="f";

$location="80218";

$weatherfile = "http://xml.weather.yahoo.com/forecastrss?p=$location&u=$units";
if (!($fp = @fopen($weatherfile, "r"))) { //Remove the "@" to see error messages.
$theResponse = "I can't seem to connect to the weather source right now. Is the internet on?";

} else {
$theResponse = "The file loaded just great.";
}
echo($theResponse);
?>
 
Old 04-18-2006, 06:15 PM   #5
Ultrus
Member
 
Registered: Jan 2006
Posts: 50

Original Poster
Rep: Reputation: 15
Yeah, I tried it on my PC Apache/PHP testing server with success. It works on my hosted website as well. When I test it on my Linux testing server laptop through, it sits for a long time, then gives me that error message.

I tried disabling my firewall. It still seems to be having the same problem. One guess is my wireless connection might be blocked somehow by the office firewall or something odd like that. This might be a far throw, but I'll know for sure when I connect this thing to the Internet at home. I'll post an update if I find anything.
 
Old 04-18-2006, 07:24 PM   #6
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Is this possibly a PHP configuration issue? Is PHP on the testing server build the same as PHP on Linux testnig laptop?

Peace...
 
Old 04-18-2006, 09:57 PM   #7
Ultrus
Member
 
Registered: Jan 2006
Posts: 50

Original Poster
Rep: Reputation: 15
Oh! That's a good tip. My Linux is using PHP4, while everything else is using PHP5. That could make a difference. It seems that Suse 10 doesn't include PHP5 on the 5 disc set. I'll start looking for a stupid-proof set of instructions for installing it on this laptop. Thanks!
 
Old 04-19-2006, 08:56 AM   #8
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
I don't think your problem is a difference between php4 and php5. This looks to be more like a permissions issue with php. You might want to take a look at your php.ini file on the laptop and see if there is anything in there that might be preventing it. For that matter, you may want to take a look at the apache server settings as well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting up a slack, apache server with php and a sql server. caged Slackware 1 10-25-2004 04:45 AM
Apache httpd not loading php pages properly. queezythegreat Linux - Networking 0 09-26-2004 03:50 PM
Apache+php on one server and MySQL on onother server? goe Linux - Newbie 3 08-19-2004 04:25 PM
PHP not loading on Apache, help! enteal Linux - Software 3 04-19-2004 10:30 AM
Loading PHP into Apache dwpondscum Linux - Software 2 10-18-2003 04:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration