You have to use full real path for flawless inclusion. Add this code into any file existed on same location where the connection.php is and use the real path which u see in the output of echo.
Main Topics
Browse All TopicsI want to include a file with local variables, like the database connection and the absolute server path. For this reason I think I need a relative path. The problem is that I'm working on an existing application and strange things are happening. The application has pages on different levels of subdirectories, with includes including other includes.
I know how to include a file using a relative path, but when I do this and browse through the site, I always get errors. Look at the two lines of code below. Line A is needed when I login. When logged in, I get the following error:
Warning: Database::include(./../../
Then I change to line B, and the error disappears. Then I do a search query, resulting in an error (changing to line A), after which I get another error when displaying the search results (changing to line B).
Any suggestions how to solve this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: elbrian87Posted on 2009-03-12 at 08:02:19ID: 23869124
By escaping to "../", you are left at the root directory.
index.php" and want to include something in another directory, use:
If you are using a file "index.php" in "/folder1/folder2/folder3/
"../folderX/folderX" as if starting from the root. Have multiple ../../../'s is definitely not working.
I hope that helps :)