RyanM Posted August 1, 2017 Share Posted August 1, 2017 So I recently moved webhost, and transferred all files over, and first time loading up my website to check everything works, I'm getting database access error (There was an error connecting to the database: Access denied for user ''@'localhost' (using password: NO)) Naturally I go over my source and check everything is ok. Database info comes from conf.json so I added a check to see if it's opening and apparently its not. Config Source: class config{ public $mysql = array(); public $table_prefix = ''; public $template_dir = 'styles'; public $config = array(); public function __construct() { global $root_path; $config_file = $root_path . '/includes/conf.json'; $data = json_decode(file_get_contents($config_file),true) or die("Could not open conf.json file"); $this->mysql = $data; return true; }} I've verified that the file is where it should be. As I said this worked fine on my old host. Permissions for the json file is 644 Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 1, 2017 Share Posted August 1, 2017 So “apparently it's not opening” means that the die() is triggered, yes? Turn the error reporting all the way up and enable logging. Then add proper error handling for the JSON parsing. If there's something wrong with the file itself, then file_get_contents() will give you an exact error message. If the parsing fails, the JSON extension will tell you. Operations in PHP don't just silently fail. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted August 2, 2017 Share Posted August 2, 2017 So I recently moved webhost, and transferred all files over, and first time loading up my website to check everything works, I'm getting database access error (There was an error connecting to the database: Access denied for user ''@'localhost' (using password: NO)) Naturally I go over my source and check everything is ok. Database info comes from conf.json so I added a check to see if it's opening and apparently its not. Config Source: class config{ public $mysql = array(); public $table_prefix = ''; public $template_dir = 'styles'; public $config = array(); public function __construct() { global $root_path; $config_file = $root_path . '/includes/conf.json'; $data = json_decode(file_get_contents($config_file),true) or die("Could not open conf.json file"); $this->mysql = $data; return true; }} I've verified that the file is where it should be. As I said this worked fine on my old host. Permissions for the json file is 644 Your $root_path is probably different on the new host. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.