RE: [PHP] fopen not opening url

From: Date: Tue, 31 Jul 2001 07:01:10 +0000
Subject: RE: [PHP] fopen not opening url
Groups: php.general 
Request: Send a blank email to php-general+get-60325@lists.php.net to get a copy of this message
Are you still having problems? Things to try: 1. Try and open the url directly in a browser. eg http://p.moreover.com/cgi-local/page?c=Music%20business%20news&o=xml Does it return data (you may need to change the &o=xml to &o=html though). Some countries (like the one I'm in China, have moreover access banned via some providers) 2. socket blocking - you may need to enable or disable this dependant on your server settings: set_socket_blocking ($connection,false); function LoadFile ($filename,$block=false){ $fd = fopen( $filename, "r" ); if ($block) set_socket_blocking ($fd,true); $contents = fread( $fd, filesize( $filename ) ); fclose( $fd ); return ($contents); } Without socket blocking LoadFile ("http://p.moreover.com/cgi-local/page?c=Music%20business%20news&o=xml"); With socket blocking LoadFile ("http://p.moreover.com/cgi-local/page?c=Music%20business%20news&o=xml",true ); 3. I use something like this for reads on difficult servers (some china mail servers are a p.i.a to get at sometimes). Function GetLine() { $timeout=30; $iStartTime = time(); set_socket_blocking($this->connection, false); $line = fread($this->connection,128); while(empty($line)){ $line = fread($this->connection,128); usleep(250000); } if ($debug) { print ($line) ."<br>"; System("echo ''"); flush; } return ($line); } Let me know how you do. Lawrence. -----Original Message----- From: Jay Paulson [mailto:jpaulson@lbjs.com] Sent: July 31, 2001 5:17 AM To: php-general@lists.php.net Subject: [PHP] fopen not opening url here's the code i'm using below to try and open up the url.. :) thanks! jay $fp = fopen("http://p.moreover.com/cgi-local/page?c=Music%20business%20news&o=xml" , "r"); $length = filesize($fp); $content = fread($fp,$length); fclose($fp); echo $content; ----- Original Message ----- From: "Jack Dempsey" <dabigdemp@hotmail.com> To: "'Jay Paulson'" <jpaulson@lbjs.com> Sent: Monday, July 30, 2001 1:52 PM Subject: RE: [PHP] fopen not opening url > Hi jay, > > I've done the exact thing you're trying, and it works...paste in some > code so we can see where its going wrong... > > jack > > -----Original Message----- > From: Jay Paulson [mailto:jpaulson@lbjs.com] > Sent: Monday, July 30, 2001 2:08 PM > To: php-general@lists.php.net > Subject: [PHP] fopen not opening url > > hello- > I'm trying to use the fopen() command to open the url below and just > read it > into another $var. However, I'm having some problems.... the warning i > get > is below along with the url in the warning. Anyone know what's going on > here?? > > Thanks, > jay > > Warning: php_hostconnect: connect failed > Warning: > > fopen("http://p.moreover.com/cgi-local/page?c=Music%20business%20news&o= > xml" > ,"r") - Bad file descriptor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#60325) next »