donnpe Posted April 21, 2010 Share Posted April 21, 2010 Hi I am having problems getting the PHP include function working on my new Apache2.2 installation on my new laptop (locahost). My standard PHP files work fine (e.g. phpinfo() shows everything is good) however if I have a file – e.g. testinclude.php below, which includes another file on localhost, I get a browser error: This works - i.e. when including page on another server: <?php include("http://"."www.hertsholistichealth.co.uk"."/testpage.html); ?> This includes a file on localhost and produces an error when entered into the browser: <?php include("http://localhost/testpage.html"); // Produces browser error below ?> Error when entering http://locahost/testinclude.php into browser: Warning: include(http://localhost/testpage.html) [function.include]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. In C:\Users\peter\Documents\WebSites\HHH\testinclude.php on line 3 I would greatly appreciate any help on what could be going wrong with the localhost include. Thanks Peter Quote Link to comment Share on other sites More sharing options...
grim1208 Posted April 21, 2010 Share Posted April 21, 2010 to start off (this has been helpful to me at least as far as determining better where the actual bug lies) is instead of using 'include' use 'include_once' or 'require_once', doing this will break the page once the error occurs from the included/required page instead of loading everything anyway Quote Link to comment Share on other sites More sharing options...
donnpe Posted April 21, 2010 Author Share Posted April 21, 2010 Thanks - I tried this but got the same error: Warning: include_once(http://localhost/testpage.html) [function.include-once]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Users\peter\Documents\WebSites\HHH\testinclude.php on line 4 Warning: include_once() [function.include]: Failed opening 'http://localhost/testpage.html' for inclusion (include_path='.;C:\php5\pear') in C:\Users\peter\Documents\WebSites\HHH\testinclude.php on line 4 Fatal error: Maximum execution time of 30 seconds exceeded in C:\Users\peter\Documents\WebSites\HHH\testinclude.php on line 5 Quote Link to comment Share on other sites More sharing options...
grim1208 Posted April 21, 2010 Share Posted April 21, 2010 dumb question but you are certain testpage.html doesn't have any errors or does exist for that matter? Quote Link to comment Share on other sites More sharing options...
donnpe Posted April 21, 2010 Author Share Posted April 21, 2010 I have entered it directly into the browser address bar and it successfully says "This is a test page"! Relevant checking though! Quote Link to comment Share on other sites More sharing options...
grim1208 Posted April 21, 2010 Share Posted April 21, 2010 php safe mode on? Quote Link to comment Share on other sites More sharing options...
donnpe Posted April 21, 2010 Author Share Posted April 21, 2010 It was off (although I tried it with it on and got the same error) Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 21, 2010 Share Posted April 21, 2010 Is there some reason you are using a URL to include a local file? You should be using a file system path to include a local file. Quote Link to comment Share on other sites More sharing options...
donnpe Posted April 21, 2010 Author Share Posted April 21, 2010 Yes - because I need to specify a query string on the end of the URL and I believe it needs to be treated as a URL in order to process it correctly. I could be wrong? Actually the line of code I really want to work is: <?php include("http://".$_SERVER["HTTP_HOST"]."/services/php/serviceDetails.php?selectlabel=Acupuncture&service_ID=78"); ?> Thanks Peter 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.