
3

Fatal error when trying to use require_once in php
source link: https://www.codesd.com/item/fatal-error-when-trying-to-use-require-once-in-php.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fatal error when trying to use require_once in php
advertisements
I am trying to connect my php script with my database in an online server. I am trying to use require_once function however, I am getting the fatal_error with the following error message.
Warning: require_once(/home/username/public_html/droidDBtest/android_login_api/include/DB_Functions.php): failed to open stream: No such file or directory in /home/username/public_html/droidDBtest/android_login_api/register.php on line 3
Fatal error: require_once(): Failed opening required '/home/username/public_html/droidDBtest/android_login_api/include/DB_Functions.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/droidDBtest/android_login_api/register.php on line 3
I tried to follow the first result's of stackoverflow and added Document Root, however, it's still not working. This is the code where I am getting an error :
require_once ($_SERVER['DOCUMENT_ROOT'].'/android_login_api/include/DB_Functions.php');
The following is my folder structure in my server
public_html/
-- droidDBtest
-- android_login_api
-- include
config.php
DB_Connect.php
DB_Functions.php
register.php
Thanks in advance.
Lookin at your directory structure, and assuming socument root is public_html, you shoud do this:
require_once ($_SERVER['DOCUMENT_ROOT'].'/droidDBtest/android_login_api/include/DB_Functions.php');
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK