Jump to content


Photo

Warning: fsockopen() [function.fsockopen]: unable to connect to ...


  • Please log in to reply
2 replies to this topic

#1 khoffman22

khoffman22
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 September 2006 - 11:55 PM

Hi,

I've been using the sourceforge project phpffl (great project if you are into fantasy football) to set up a fantasy football league for my friends and have run into a kind of odd php problem.  The guys over at phpffl tried to help but gave me a test to determine if it was just phpffl or php in general and it looks like php in general so here I am...

Here's the scoop:
there is a update that is run to get player stats for scoring (statistics.php).  If I run a cron job that runs this file (php /pathname/statistics.php > stats.out) (the redirect is just so I can see some results, actual updating is in a mysql database), it works fine.

If I run the file from the browser (which the guys at phpffl says should work), a la
http://somename.com/.../statistics.php

it doesn't work.  I get a sort of empty set results.  Turning on more error handling for php reveals the following error:
Warning: fsockopen() [function.fsockopen]: unable to connect to myffl.net:80 (Permission denied) in /var/www/html/ffl/program_files/autorun/myffl/functions/statistics_functions.php on line 55

Now, why isn't this a phpffl problem?  Well, I created the following file in the same directory:
<?php
ini_set("display_errors", "On");

$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {
   $out = "GET / HTTP/1.1\r\n";
   $out .= "Host: www.example.com\r\n";
   $out .= "Connection: Close\r\n\r\n";

   fwrite($fp, $out);
   while (!feof($fp)) {
       echo fgets($fp, 128);
   }
   fclose($fp);
}
?>

I get the same error:
Warning: fsockopen() [function.fsockopen]: unable to connect to www.google.com:80 (Permission denied) in /var/www/html/ffl/program_files/autorun/myffl/test.php on line 4
Permission denied (13)

So I guess php isn't being allowed to open a connection.  I'm pretty new to fooling with php but have some knowledge about stuff otherwise.

Oh, I'm running Fedora Core 5 with pretty standard firewall/SELinux settings (ports open for HTTP, SSH, mail, TS) behind a consumer wireless router.

Thanks for any help you can give me.

Keith

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 20 September 2006 - 01:10 AM

You'll want to look in your php.ini for allow_url_fopen, make sure it is switched to On.

#3 khoffman22

khoffman22
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 September 2006 - 05:37 PM

Thanks for the suggestion.  Didn't see your reply for awhile.  New to phpfreaks.com and didn't realize that it doesn't auto-notify.
allow_url_fopen is on.  Any other suggestions?  Here is that section of my php.ini file.

;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;;;;;;;;;;;;;;;;;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

; Define the anonymous ftp password (your email address)
;from="john@doe.com"

; Define the User-Agent string
; user_agent="PHP"

; Default timeout for socket based streams (seconds)
default_socket_timeout = 60

; If your scripts have to deal with files from Macintosh systems,
; or you are running on a Mac and need to deal with files from
; unix or win32 systems, setting this flag will cause PHP to
; automatically detect the EOL character in those files so that
; fgets() and file() will work regardless of the source of the file.
; auto_detect_line_endings = Off

:





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users