Answer the question
In order to leave comments, you need to log in
How to handle database connection errors in Codeigniter?
During installation, the user enters his data for connecting to the database, you need to process them and in case of some error try to suggest what the problem is (name \ host \ password), I try to connect to the database with incorrect data, an error just falls out, how can I process it so that I could mistakenly write hints to the user. Googled, googled for a long time, googled in different languages, googled nothing (
public function dbtest(){
$host=htmlspecialchars(trim($this->input->post('dbhost')));
$user=htmlspecialchars(trim($this->input->post('dbuser')));
$password=htmlspecialchars(trim($this->input->post('dbpassword')));
$database=htmlspecialchars(trim($this->input->post('dbname')));
$databseConfig = array(
'hostname'=>$host,
'username'=>$user,
'password'=>$password,
'dbdriver' => 'mysqli',
);
$this->load->database($databseConfig);
}
Answer the question
In order to leave comments, you need to log in
How to handle database connection errors in Codeigniter?Probably the solution that I will offer is not the best in terms of architecture ... but CodeIgniter itself is not a masterpiece of architectural solutions in its field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question