CodeIgniter Forums
Error in the query database ? - 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: Error in the query database ? (/showthread.php?tid=65359)



Error in the query database ? - jocm.aguiar - 06-02-2016

Hi guys.
I'm running into me with the following error to list database data:
Link: http://build.elevsaude.com/
Would anyone help me? For I see no error in the code below:

Controller file:
public function index() {
// Model load
$this->load->model('Runcode_model');
// Method run
$data['links'] = $this->Runcode_model->links_list();
// View load
$this->load->view('runcode', $data);
}

Model file:
class Runcode_model extends CI_Model {
public $elev_opera_id;
public $elev_opera_date;
public $elev_opera_hours;
public $ws_safe_id;
public $elev_opera_name;
public $elev_opera_logo;
public $elev_opera_link;

public function __construct() { 
parent::__construct();
}

// metodo que lista links das operadoras:
public function links_list() {
$query = $this->db->get('elev_operators'); Line 19
return $query->result();
}
}

View Archive:
<?php endforeach;
foreach ($links as $view) {
echo '<a class="orators-links-strucs"><img src="assets/fgs/'. $view->elev_opera_logo .'" class="orators-links-zoom-strucs"></a>';
};
?>



RE: Error in the query database ? - ivantcholakov - 06-02-2016

Connect to database. http://www.codeigniter.com/user_guide/database/connecting.html#automatically-connecting
https://github.com/bcit-ci/CodeIgniter/blob/3.0.6/application/config/autoload.php#L54

Code:
$autoload['libraries'] = array(
    'database',
    // ... other libraries if needed.
);



RE: Error in the query database ? - jocm.aguiar - 06-02-2016

(06-02-2016, 02:07 PM)ivantcholakov Wrote: Connect to database. http://www.codeigniter.com/user_guide/database/connecting.html#automatically-connecting
https://github.com/bcit-ci/CodeIgniter/blob/3.0.6/application/config/autoload.php#L54

Code:
$autoload['libraries'] = array(
   'database',
   // ... other libraries if needed.
);

Thanks for the reply, actually forgot to assign.

I tried to run to see the result and I am faced with the following error (assuming that the database access settings are correct). Follow the link from the results: http://build.elevsaude.com


RE: Error in the query database ? - ivantcholakov - 06-02-2016

If your username and password for MySQL are correct, then the circumstance that you are trying to access the MySQL server from the address 167.114.27.173 becomes important.

Usually MySQL is configured to accept connections from localhost for security reason. You have to check how the user wsprojcm_user is allowed to connect.

If the web-server and MySQL are installed on a same machine, then change 167.114.27.173 to localhost and see what would happen. Otherwise you have to negotiate with the MySQL server owner/administrator how the connection to be made.