Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include .php file in folder above

Tags:

php

I am receiving this error

Warning: include(../config.php) [function.include]: failed to open stream: No such file or directory in /home/soizastu/public_html/cms/happy-api/retrieve.php on line 2

Warning: include() [function.include]: Failed opening '../config.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/soizastu/public_html/cms/happy-api/retrieve.php on line 2

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'soizastu'@'localhost' (using password: NO) in /home/soizastu/public_html/cms/happy-api/retrieve.php on line 6
Error connecting to database.

basically in the cms folder is config.php i thought include "../config.php"; would do the trick but it dosent appear so.

like image 466
user393273 Avatar asked Nov 25 '10 22:11

user393273


2 Answers

Try computing the absolute path and including that.

include(dirname(__FILE__)."/../config.php");

I think it's the safest bet when dealing with multiple levels of include.

like image 197
Alin Purcaru Avatar answered Nov 01 '22 01:11

Alin Purcaru


Make sure that the user you're using to run your web server can read the file. For a sanity check, chmod the file to 665. If it's a Windows system, then make it so that Everyone can read the file.

like image 38
Sam Bisbee Avatar answered Nov 01 '22 01:11

Sam Bisbee