Reputation: 19310
Attached image shows the location of files it will help you to give answer. I want to include 'db/functions.php'
in my file 'process/delete.php'
but nothing is working.
I have tried following at start of 'delete.php'
include_once '/db/functions.php';
include_once './db/functions.php';
include_once '../db/functions.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/db/functions.php';
When I open MAMP/log/php_error.log file it shows following error
[28-Jul-2012 21:55:23] PHP Warning: include_once()
[<a href='function.include'>function.include</a>]:
Failed opening '/db/functions.php' for inclusion
(include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in
/Applications/MAMP/htdocs/electromart/process/delete.php on line 3
Where line 3 is include statement.
Upvotes: 2
Views: 367
Reputation: 26376
From the error you could see the electromart
folder is missing in the path and when you move to another machine the directory structure might change too depending on how the server is setup. Try
include_once $_SERVER['DOCUMENT_ROOT'].'/electromart/db/functions.php';
Upvotes: 2
Reputation: 2116
Try this: include_once realpath(dirname(__FILE__)."../db/functions.php");
Upvotes: 2