Jump to content

Problem with php include function on localhost apache2.2


Recommended Posts

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.