0

I'm trying to build myself a website using PHP and MySQL. I get the below error:

Fatal error: require_once(): Failed opening required '/home/konjam /public_html/demo/cp/db.php' (include_path='.:/Applications/XAMPP/xamppfiles /lib/php') in /Applications/XAMPP/xamppfiles/htdocs/KD/demo/cat_details.php on line 5

Here's my code for the line where it says this specific error:

<?php ob_start(); session_start(); require_once("conf.php"); require_once("db.php"); $db = new db(); ?> 

Any help guys?

9
  • Is the file in the same directory as this script? Commented Jan 29, 2015 at 11:41
  • Are you sure the db.conf file is within same location as file script? Commented Jan 29, 2015 at 11:41
  • use absolute paths for require include etc or take sure, that include_path is in your sens Commented Jan 29, 2015 at 11:41
  • See stackoverflow.com/questions/7835948/… for a similar question, complete with answers. Commented Jan 29, 2015 at 11:43
  • Yes. The file is in the same directory. Commented Jan 29, 2015 at 11:43

2 Answers 2

3

Maybe it'll surprise you but there is no /home/konjam/public_html/demo/cp/db.php file and PHP can't include it in your code.

Make sure you specify correct path to that file (maybe use dirname(__FILE__) and relative path?) and that PHP have rights to read it.

Sign up to request clarification or add additional context in comments.

3 Comments

__DIR__ works as well as dirname(__FILE__) unless you're on a really old version of PHP
@CD001: yep, I really don't know why I'm still using dirname(__FILE__).. ;)
@ElonThan I tried require_once(CP.'db.php'); and it still didn't work. I put the db.php file in a folder called cp.
0

the application is taken from a linux machine and put on a windows machine, in XAMPP. you have to search for all "/home/konjam/public_html" strings in your project folder in xampp and modify the references properly, from linux to windows. It would be best to work with relative paths.

1 Comment

Just changing the PHP include_path setting would probably sort it in this instance.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.