Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

include_once() stopped working in PHP5

I just noticed my website shows only white page, I have the following php code the link functions


<?php
// Links functions for all pages
$go = $_GET['go'];

switch ($go) {

  case 'sitemap' : include_once 'http://localhost/info.php';
  break;
  case 'help' : include_once 'http://localhost/contactus.php';
  break;
  case 'beta' : include_once 'http://localhost/beta.php';
  break;
  case '' : include "http://localhost/index.htm";
  break;

}
     
?>

I just upgraded my PHP to version 5 and it was working on version 4.
I didn't get any error, threrfore I installed XAMPP on my computer to see if the problem from my server or the code I have,
and the good thing in XAMPP is I can switch between PHP 4 and 5 with one click, so on PHP 4 it worked fine but on PHP5 I get the following error:


Warning: include() [function.include]: URL file-access is disabled in the server configuration in D:\xampp\htdocs\index.php on line 62

Warning: include(http://localhost/index.htm) [function.include]: failed to open stream: no suitable wrapper could be found in D:\xampp\htdocs\index.php on line 62

Warning: include() [function.include]: Failed opening 'http://localhost/index.htm' for inclusion (include_path='.;D:\xampp\php\pear\') in D:\xampp\htdocs\index.php on line 62

I checked Experts Exchange and Google for a solution for this error and the only thing I got from php.net is I have to enable allow_url_include in php.ini
but I done that and nothing changed still getting that same error message.!!
anyone got accross the problem before? could help me out.

Thank you,
0
maxnca
Asked:
maxnca
  • 5
  • 4
  • 4
  • +2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
include_once, by default in php5, does not allow http references:
Warning: include() [function.include]: URL file-access is disabled in the server configuration

>the only thing I got from php.net is I have to enable allow_url_include in php.ini
yes, that is correct.
now, did you modify the correct php.ini? by default, it is the one in windows folder...
please clarify
0
 
nizsmoDeveloperCommented:
as angellll said, its a permission problem to do with URL include http://....

Where is your script located? if it is located in the root directory of localhost why not try below:
<?php  		  	
// Links functions for all pages
$go = $_GET['go'];
 
switch ($go) {
  case 'sitemap' : 
  include_once('info.php');
  break;
  case 'help' : 
  include_once('contactus.php');
  break;
  case 'beta' : 
  include_once('beta.php');
  break;
  case '' : 
  include("index.htm");
  break;
 
}
     
?>

Open in new window

0
 
maxncaAuthor Commented:
angelll: yes i edited the corrected php.ini because XAMPP has only one php.ini file in its php folder.

nizsmo: it is the root directory, and I tried the modifide codes you  posted but got the same error.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if with the modified code you get the same error, it must be some other place in the code that actually raises the problem?
0
 
nizsmoDeveloperCommented:
can you try require('file.html") and see if it gives the same error?
0
 
maxncaAuthor Commented:
I tried require() and gave me the same error.!
0
 
nizsmoDeveloperCommented:
please copy and paste the error? EXACTLY the same? or slightly different?
0
 
maxncaAuthor Commented:

Warning: require() [function.require]: URL file-access is disabled in the server configuration in D:\xampp\htdocs\index.php on line 62

Warning: require(http://localhost/index.htm) [function.require]: failed to open stream: no suitable wrapper could be found in D:\xampp\htdocs\index.php on line 62

Fatal error: require() [function.require]: Failed opening required 'http://localhost/index.htm' (include_path='.;D:\xampp\php\pear\') in D:\xampp\htdocs\index.php on line 62
0
 
steelseth12Commented:
As angelIII said above allow_url_include needs to be on.

make a new file and put in the following code

<? phpinfo(); ?>

and check if allow_url_include is set to on.

Check also the path to the php.ini to make sure you are editing the correct one.

For any changes in php.ini to take effect you need to restart the server.
0
 
nizsmoDeveloperCommented:
try the require without the http://? it is best to include/require your files without the http:// anyway as then the path is relative and only has to be in the same directory as the script. otherwise in the future when you upload your script to another server you will encounter problems with these include/require paths.
0
 
RoonaanCommented:
Can you try and change your code to:

  case 'sitemap' : include_once 'info.php';
  break;
  case 'help' : include_once 'contactus.php';
  break;
  case 'beta' : include_once 'beta.php';
  break;
  case '' : readfile("index.htm");
  break;

As mentioned, it is inefficient en unnecessairy to use include_once 'http://localhost/....'

Kind regards

-r-
0
 
maxncaAuthor Commented:
ok, I tried everything you said and nothing changed,!!
but what I noticed the line allow_url_include is not showing in the PHP info page, even when i went to the file I see it set to "on" and I used the same php.ini file to edit that is listed under Configuration File (php.ini) Path : /usr/local/Zend/etc/php.ini  and restarted apache couple of time but is not showing up !!!
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
then, let me repeat: check if you have a php.ini file in the windows folder.
0
 
RoonaanCommented:
@angelIII

He's probably running on linux, as his php.ini path is at /usr/local/Zend/etc/php.ini

@maxnca,

Can you check if there is a php.ini at /etc/php.ini ?

-r-
0
 
steelseth12Commented:
Ok something is wrong here ....


Warning: require(http://localhost/index.htm) [function.require]: failed to open stream: no suitable wrapper could be found in D:\xampp\htdocs\index.php on line 62

 D:\xampp\htdocs\index.php === Windows machine

Path : /usr/local/Zend/etc/php.ini === *inx

???
0
 
maxncaAuthor Commented:
Sorry let me clear things up I'm running the file on both windows and linux on windows it is working fine now after adding the allow_url_include inside the php.ini
but in linux still not working even I added it in php.ini,

Roonaan: there is no php.ini in /etc
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I agree with steelseth12... something is wrong ...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now