require once - require_once in PHP giving errors on new server, but not on original -


i in process of moving php website shared hosting server digitalocean server. have come across issue i'm not sure how debug.

there page has log-in form action=2/login.php. form located in /var/www/html/calendar.php (it ubuntu 14.04 droplet). when submitting form, there 500 internal server error. i've found error in question not sure how debug (because runs fine on other server).

/var/www/html/2/login.php

<?php require_once('../db_connect.php'); ... 

db_connect.php located @ /var/www/html/db_connect.php

when $php 2/login.php following error:

login_error.txt

php warning:  require_once(../db_connect.php): failed open stream: no such file or directory in /var/www/html/2/login.php on line 4 php fatal error:  require_once(): failed opening required '../db_connect.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/2/login.php on line 4 

when run $php login.php when in directory /var/www/html/2 works fine (which guess makes sense, ../db_connect.php relative path).

i want know why working on other server , not server?

the php.ini same (which problem), on server #1 (verve), shared hosting, our root /home/[username]/public_html , on new server is /var/www/html.

i can link live sites in question if necessary (but prefer not to). /var/www/html/2/login.php , /var/www/html/calendar.php scripts same, , while understand cause issues later absolute path root of web application different, don't know causing specific issue.

i have looked @ question similar: php require_once resetting current working directory. however, code works on other server, , not here, think there more lack of relative file path, , prefer find solution explains why script isn't working rather patching script, i'm pretty sure i'd have change every single other script uses require_once('../db_connect.php') well.

thanks help!

did try using __dir__?

require_once(__dir__ . '../db_connect.php'); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -