• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

php include file

i am building a website and have to include some files but i am getting this error


Warning: include(../db/database.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\cart\admin\includes\session-check.php  on line 9


here is the code:

home.php

<?php
include('includes/session-check.php');
?>

session-check.php

<?php
session_start();  
include('../db/database.php');
?>

database.php is a file in folder db

can you tell me what am i doing wrong?
<?php
include('includes/session-check.php');
?>

Open in new window

0
nandananushil1
Asked:
nandananushil1
1 Solution
 
doyledpCommented:
The include command performs the include relative to the original calling script. i.e. home.php in your case.

So the include('../db/database.php'); in fact refers to the file database.php that is in the db folder that is in the same folder as your home.php file. Can you check that this is the case.
0
 
syedyounusCommented:
<?php
session_start();  
include('../db/database.php');
?>

change this to

<?php
session_start();  
include('db/database.php');
?>

assuming db(folder) --- is in admin folder

If this does not work let us know what is the exact location of the db folder
0
 
theodorejsalvoCommented:
If you use a full path to your include, then it will register no matter what directory the calling file is in.

Full paths start with the slash '/'.  For example:
include('/db/database.php');

Open in new window

0
 
gmckeown99Commented:
Do you have "include_path" set in php.ini? You can add multiple paths, just make sure they are outside your main document root.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now