简体   繁体   中英

Issue with custom config.php

I have been dropped in the deep end by being asked to migrate an OLD custom built website (using php and mysql) to another server. I have changed the config to reflect the new location but all I get is a white screen. The DB connects fine so that isn't the issue, I think it might be with the $doc_root. Can anyone help with the code below?

$doc_root = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])))."";
$DOC_ROOT = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])))."";

I dont know php too well unfortunately so I am stuck! The current test server address is in this format http://xx.xxx.xx.xx/thedomain.com/

I have tried so many combinations of the above for the $doc_root but whatever I do won't work.

Can anyone help? Thanks in advance!

Edit your php.ini file and enter the following line:

error_reporting = E_ALL

This will report the exact error as to where your code is going wrong instead of a blank page.

Another method is to run the the command

$php <php-filename>

If you report the error here, maybe then one can help you more.

You could use this code for reference:

//Directory sub-folder, if the file is not under the sub-folder leave it blank
//if under a folder add this example ('/folder')
if (!defined("DIRECTORY_FOLDER")) define(DIRECTORY_FOLDER, "");

//DIRECTORY_ROOT is the document root of the file ex: /home/user/public_html
if (!defined("DIRECTORY_ROOT")) define(DIRECTORY_ROOT, $_SERVER["DOCUMENT_ROOT"].DIRECTORY_FOLDER); 

//here is the url of the website
if (!defined("DEFAULT_URL")) define(DEFAULT_URL, "http://".$_SERVER["HTTP_HOST"].EDIRECTORY_FOLDER);

You can use now the DEFAULT_URL and the DIRECTORY_ROOT as a variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM