Confusion101 Posted April 3, 2007 Share Posted April 3, 2007 A piece of my code performs scheduling by using a ./board/scheduler.php to get urls from a database and than including those url's. e.g.: include($event); where $event might contain "http://www.example.com/board/deletepost.php?poster=me&post=yesterday" This used to work fine for the longest time, until I started receiving this error: Error: [2] include(http://www.example.com/board/deletepost.php?poster=me&post=yesterday) [<a href='function.include'>function.include</a>]: failed to open stream: Connection refused in /usr/www/www.example.com/board/deletepost.php on line 46 The & is an ampersand in the code for sure. Somehow it gets changed in the errorlog procedure. Also I tried to put a php.ini file in the root and the board directory to ensure that allow_url_fopen was on. Then I tried to add the following: ini_set("include_path",".;http://www.example.com/board"); ini_set("allow_url_fopen","On"); Could anyone explain what's going wrong and how to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/ Share on other sites More sharing options...
Daniel0 Posted April 3, 2007 Share Posted April 3, 2007 allow_url_include needs to be on. allow_url_fopen is for fopen(), but allow_url_include is for include()/require()/include_once()/require_once(). Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-220464 Share on other sites More sharing options...
Confusion101 Posted April 4, 2007 Author Share Posted April 4, 2007 Ok, I tried to turn it on in the php.ini file and I tried to add ini_set("allow_url_include","On"); inline, but neither worked. A strange thing I noticed was that even though I added php.ini to in both www.example.com and the board directory, when I run phpinfo (from either directory) it seems as if the settings are unchanged, both local and master value are the same, but not the value I gave it in the php.ini file? For completion: The server is Apache/1.3.37 (Unix) running PHP/5.1.5 Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-220962 Share on other sites More sharing options...
Daniel0 Posted April 4, 2007 Share Posted April 4, 2007 When running phpinfo(), the first section has a field called "Configuration File (php.ini) Path". The file mentioned there is the one you need to change. Safe mode might have effect on this too. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221020 Share on other sites More sharing options...
Confusion101 Posted April 4, 2007 Author Share Posted April 4, 2007 Thanks. I don't seem to have access. I'll contact the one who should have. Nevertheless doesn't php first look at the php.ini file in the directory of the file that's being executed? Also shouldn't ini_set's change something. Finally and most importantly, despite some mentions about an earlier version, allow_url_include isn't introduced until php 5.2 and I'm running 5.1.5. I've verified that allow_url_fopen is on, so the problem should be elsewhere. Any ideas anyone? Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221136 Share on other sites More sharing options...
Confusion101 Posted April 5, 2007 Author Share Posted April 5, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221743 Share on other sites More sharing options...
btherl Posted April 5, 2007 Share Posted April 5, 2007 "Connection refused in /usr/www/www.example.com/board/deletepost.php on line 46" This is talking about an error in deletepost.php, not in your scheduler. Also, it's very strange to use include() to call a script using a URL. include() is usually for local files. CURL or file_get_contents() would make more sense. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221746 Share on other sites More sharing options...
Fergusfer Posted April 5, 2007 Share Posted April 5, 2007 A few things. First and foremost, this is a bad idea. I don't think you should include from a remote server. However, if you insist, please be aware: re: allow_url_fopen Note: This setting can only be set in php.ini due to security reasons. http://ca.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen ini_set() has a return value (false on failure). Because not all ini values can be set using ini_set and because security settings may prohibit certain changes, you ought to check the return value of ini_set() rather than assuming it will succeed. You should examine the error you are getting closely: failed to open stream: Connection refused in /usr/www/www.example.com/board/deletepost.php on line 46 Connection refused means your connection is not accepted by the remote host. I think you need to fix the server, not the client. Finally, please note that this is non-portable code: ini_set("include_path",".;http://www.example.com/board"); The correct form is: ini_set('include_path', '.' . PATH_SEPARATOR . 'http://www.example.com/board'); Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221750 Share on other sites More sharing options...
Confusion101 Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks for the replies. First of all I messed up; The error was: Error: [2] include(http://www.example.com/board/deletepost.php?poster=me&post=yesterday) [<a href='function.include'>function.include</a>]: failed to open stream: Connection refused in /usr/www/www.example.com/board/scheduler.php on line 47 The error was generated in the scheduler. The reason for using include here is to run the the code of deletepost (which is on the same server) with specific parameters, without actually including any of it's methods. If you look at the specifications of include you'll see the difference between including an url and including a file. I am indeed unable to change the configuration, but get_cfg_var on allow_url_fopen and allow_url_include return 1 and nothing at all respectivaly. Thus allow_url_fopen is on and allow_url_include is not in place in php 1.5.1. Those settings should thus not be the culprit. I'm recoding the whole bunch, so that I no longer have to rely on this construction, but I'd still like to learn why it's failing, especially since it used to work. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221793 Share on other sites More sharing options...
Fergusfer Posted April 5, 2007 Share Posted April 5, 2007 The error was generated in the scheduler. The reason for using include here is to run the the code of deletepost (which is on the same server) with specific parameters, without actually including any of it's methods. If you look at the specifications of include you'll see the difference between including an url and including a file. I do not understand "run the code ... without actually including any of it's [sic] methods". I do not understand why you need to use include() to obtain a file on the same server. I also would expect that the web server would provide the output of deletepost.php rather than its code if you access it by URL. You could provide parameters to a file include() by defining variables prior to but within the same scope as the include() function call. I'm recoding the whole bunch, so that I no longer have to rely on this construction, but I'd still like to learn why it's failing, especially since it used to work. As I previously posted, "connection refused" is an indication that the server (Apache?) is refusing the in-bound connection. This is not a problem with the client (the PHP script) per se. I do not know why the server is refusing the connection. Were I the programmer, I would use the Live HTTP Headers extension to Firefox to examine the request and response in greater depth. I'd confirm that the server is bound to port 80. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221830 Share on other sites More sharing options...
Fergusfer Posted April 5, 2007 Share Posted April 5, 2007 Oh, based on your use of a semi-colon in the include_path, I suppose you're actually using IIS. In any event, though, the same theory applies. Verify that it is bound to port 80. Try navigating to that URL with your browser. Do you successfully connect and see output? Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221834 Share on other sites More sharing options...
Confusion101 Posted April 5, 2007 Author Share Posted April 5, 2007 According to phpinfo() I'm running "Apache/1.3.37 (Unix)". The server_port is 80 and I can manually navigate that page or normally include it (i.e. include("deletepost.php")), I just can't URL include it. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221862 Share on other sites More sharing options...
Fergusfer Posted April 5, 2007 Share Posted April 5, 2007 According to phpinfo() I'm running "Apache/1.3.37 (Unix)". The server_port is 80 and I can manually navigate that page or normally include it (i.e. include("deletepost.php")), I just can't URL include it. I'd like to see your phpinfo() output. It seems this is a server configuration issue either in Apache or PHP. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221880 Share on other sites More sharing options...
btherl Posted April 5, 2007 Share Posted April 5, 2007 The error was generated in the scheduler. The reason for using include here is to run the the code of deletepost (which is on the same server) with specific parameters, without actually including any of it's methods. If you look at the specifications of include you'll see the difference between including an url and including a file. You should use readfile() instead, as suggested in the manual: http://sg.php.net/manual/en/function.include.php But I don't expect that will fix the error. If you're familiar with curl, try connecting to the URL using that and see what happens. "Connection refused" indicates that php can't connect to the webserver. Quote Link to comment https://forums.phpfreaks.com/topic/45404-include-error-connection-refused/#findComment-221886 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.