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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.