Jump to content

Can't open conf.json file?


RyanM

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.