I got this error when I was uploading my files to my host server, particularly when I started uploading my models.
SQLSTATE[HY000] [2002] Connection refused
Filename: controllers/Arena.php
Line Number: 13
I am using codeigniter as the php framework and 000webhost.com for my free hosting needs.
example of my model
<?php
class Image_model extends CI_Model{
function get_image_data(){
$this->load->database();
$this->db->select('nuotrauka,id,kalba');
$this->db->where('kalba', 'lt');
$query = $this->db->get('events');
return $query->result();
}
}
my controller
<?php
class Arena extends MY_Controller{
public function display(){
$this->load->model('Image_model');
$data['images'] = $this->Image_model->get_image_data();
$this->load->view('includes/head');
$this->load->view('includes/header', $data);
$this->load->view('includes/footer');
}
}
and my database.php
$db['default'] = array(
'dsn' => 'mysql:host=files.000webhost.com; dbname=id692581_name; charset=utf8;',
'hostname' => 'files.000webhost.com',
'username' => 'id692581_username',
'password' => 'password',
'database' => 'id692581_name',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I'm sitting on this error for the second day and it is making me crazy