CodeIgniter Forums
Database error in localhost - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Database error in localhost (/showthread.php?tid=72862)



Database error in localhost - scatman98 - 02-20-2019

i downloaded the website from server to localhost and getting the following error

PHP Code:
A Database Error Occurred
Unable to connect to your database server using the provided settings
.

Filenamecontrollers/Home.php

Line Number
24 


This is whats contained in the Home.php file

PHP Code:
    *         http://example.com/index.php/welcome
     
*    - or -
     *         
http://example.com/index.php/welcome/index
     
*    - or -
     * 
Since this controller is set as the default controller in
     
config/routes.phpit's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see https://codeigniter.com/user_guide/general/urls.html
     */


        public function __construct(){
                parent::__construct();
                 $this->load->helper('
form');
                 $this->load->library('
user_agent');
                 $this->load->library('
paypal_lib');
                 $this->load->model('
Ad_model', 'Ad_user');
                 $this->load->model('
User_model', 'user_model');
              $this->load->library('
VRClient');
                 $this->load->library('
form_validation');
           } 



How do i resolve this?


RE: Database error in localhost - php_rocs - 02-20-2019

@scatman98,

Which one is line 24 (VRClient or form_validation)?

I'm surprised that you didn't do this instead: $this->load->library(array('user_agent','paypal_lib','VRClient','form_validation')) or
$this->load->library(['user_agent','paypal_lib','VRClient','form_validation'])
Are Ad_model and Ad_user two different models or are you using Ad_user as the object name same for User_model?


RE: Database error in localhost - ciadmin - 02-21-2019

I am guessing that your line 24 is the first time you try to load a model ('Ad_model).
The error message indicates that your database settings are incorrect.
Those are in application/config/database.php, or possibly an environment-specific folder inside that.


RE: Database error in localhost - scatman98 - 02-21-2019

(02-20-2019, 09:01 PM)php_rocs Wrote: @scatman98,

Which one is line 24 (VRClient or form_validation)?

I'm surprised that you didn't do this instead: $this->load->library(array('user_agent','paypal_lib','VRClient','form_validation')) or
                                              $this->load->library(['user_agent','paypal_lib','VRClient','form_validation'])
Are Ad_model and Ad_user two different models or are you using Ad_user as the object name same for User_model?

24th line is

               
Code:
parent::__construct();


okay thanks for telling me about this, im just getting started with programming. this is someone elses work which im trying to study.


RE: Database error in localhost - scatman98 - 02-21-2019

(02-21-2019, 01:27 AM)ciadmin Wrote: I am guessing that your line 24 is the first time you try to load a model ('Ad_model).
The error message indicates that your database settings are incorrect.
Those are in application/config/database.php, or possibly an environment-specific folder inside that.

yes you are right. the username and password were not specified.