sanchez77 Posted November 2, 2009 Share Posted November 2, 2009 Hi Everyone, For a long time i have been using fopen to read a web page and then display it on my page. But recently, it stopped working. Does anyone know an alternative that I can use? My code is below. <?php $filename="http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/an/anz451.txt"; $fp = fopen($filename,'r'); while($line=fgets($fp)) { print $line."<br>"; } fclose($fp); ?> Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 lets just stop there a second, why has it stopped working, where is the error, you can clean out the data from now on and get rid of anything that causes the error. show us error codes you are getting etc try error_reporting(2047); before your code Quote Link to comment Share on other sites More sharing options...
sanchez77 Posted November 2, 2009 Author Share Posted November 2, 2009 when i place the code below before it, it returns a blank page. did i write it right? do i need to add more to capture the error? error_reporting(2047); Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 is there anything included above this code in an include or somthing else or some other code ? . Quote Link to comment Share on other sites More sharing options...
sanchez77 Posted November 2, 2009 Author Share Posted November 2, 2009 no, just the code that i wrote above. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 type echo "hello" before everything, and see if you get a result what kind of system is this, an in house system, is this something you built or is this a third party software,framework ? Quote Link to comment Share on other sites More sharing options...
sanchez77 Posted November 2, 2009 Author Share Posted November 2, 2009 the hellos show. it yahoo hosting, and it's just the code to read the file. nothing special. Is it possible yahoo changed security settings to not allow fopen? Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 the hellos show. it yahoo hosting, and it's just the code to read the file. nothing special. Is it possible yahoo changed security settings to not allow fopen? maybe, lets look around for another way i will get back to you brb Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 http://uk2.php.net/manual/en/function.http-request.php Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 Example 1. GET example <?php $r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET); $r->setOptions(array('lastmodified' => filemtime('local.rss'))); $r->addQueryData(array('category' => 3)); try { $r->send(); if ($r->getResponseCode() == 200) { file_put_contents('local.rss', $r->getResponseBody()); } } catch (HttpException $ex) { echo $ex; } ?> Example 2. POST example <?php $r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST); $r->setOptions(array('cookies' => array('lang' => 'de'))); $r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t')); $r->addPostFile('image', 'profile.jpg', 'image/jpeg'); try { echo $r->send()->getBody(); } catch (HttpException $ex) { echo $ex; } ?> Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 u need to install and work out how to use PECL http://www.pecl.php.net/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.