Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: require_once(): Failed opening required

I'm trying to run my online site on my local machine. I stumbled upon a problem.

This is my htaccess

AddDefaultCharset UTF-8
Options -Indexes
#php_value include_path .:/home/sites/www.example.it/example.it/htdocs/conf/

php_value include_path .:/XAMPP/htdocs/conf/

php_value display_errors on
php_value upload_max_filesize 20M
php_value post_max_size 50M
php_flag magic_quotes_gpc Off

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on

#RewriteBase /
#RewriteCond %{HTTP_HOST} ^example.it [NC]
#RewriteRule ^(.*)$ http://www.example.it/ [L,R=301]

</IfModule>

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   RewriteEngine on

   RewriteCond %{REQUEST_URI} /common.*
   RewriteRule ^common/(.*) resources/media/common/$1

   RewriteCond %{REQUEST_URI} /upload/img.*
   RewriteRule ^upload/img/(.*)$ wapp/ir.php?path=$1&%{QUERY_STRING}   

   RewriteCond %{REQUEST_URI} /upload.*
   RewriteRule ^upload/(.*) resources/upload/$1

   RewriteCond %{REQUEST_URI} !/google.*
   RewriteCond %{REQUEST_URI} !/common.*
   RewriteCond %{REQUEST_URI} !/upload.* 
   RewriteCond %{REQUEST_URI} !/upload/img/.* 
   RewriteCond %{REQUEST_URI} !/wapp/ir.php 
   RewriteRule ^(.*)$ wapp/index.php?url=$1
</IfModule>

The error I receive:

Warning: require_once(conf.inc.php): failed to open stream: No such file or directory in C:\XAMPP\htdocs\wapp\index.php on line 2

Fatal error: require_once(): Failed opening required 'conf.inc.php' (include_path='.:/XAMPP/htdocs/conf/') in C:\XAMPP\htdocs\wapp\index.php on line 2

How can I solve it? Maybe it deals with the privileges of the xampp user ...

edit:

getcwd() gives me C:\XAMPP\htdocs\wapp

conf.inc.php is located in: C:\XAMPP\htdocs\conf\

the require in index.php: require_once("conf.inc.php");

like image 998
Massimo Variolo Avatar asked Jan 15 '14 09:01

Massimo Variolo


1 Answers

try chdir(dirname(__FILE__)) this sets the relative path to the path of the file. So C:\XAMPP\htdocs\wapp\ becomes your "root directory" and therefore config.inc.php is the same as C:\XAMPP\htdocs\wapp\config.inc.php. If this still doesn't to the trick check your file paths

Edit:

You have to traverse there. Check the relative root of the project (getcwd()). I assume its C:\XAMPP\htdocs\wapp\ you have to change your require to this:

require_once ('../conf/conf.inc.php') the .. make you go up one directory

OK just do this:

require_once("../conf/conf.inc.php");

like image 103
Soundz Avatar answered Nov 07 '22 17:11

Soundz