CodeIgniter Forums
can't pull values from table but insert is ok - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: can't pull values from table but insert is ok (/showthread.php?tid=55562)



can't pull values from table but insert is ok - El Forum - 11-01-2012

[eluser]teddy[/eluser]
I waste a lot of time because I can't select some values from table, I can insert to database table on host but can't get it with select query, at local everything is ok I can select, insert.

And below is my code, if I remove two lines mark [x] I can load view template success, If not the browse firefox, chrome is not show anything I just get a white page, I don't know where is my wrong, thank you for reading my topic

My autoload.php

Code:
$autoload['libraries'] = array('database','session');

My common model
Quote:function getTinhThanhPho()
{

$sql="select id,ten_tinh from tbl_tinhthanhpho";
$rs=$this->db->query($sql)->result_array();

return $rs;
}

and in my controller function I get values return from common model

Quote:function show()
{
[x] $tinhthanhpho=$this->common_model->getTinhThanhPho();
[x] $data['tinhthanhpho']=$tinhthanhpho;
$this->load->view('index',$data);
}



can't pull values from table but insert is ok - El Forum - 11-01-2012

[eluser]CroNiX[/eluser]
Are you loading the model?

Do you have php error reporting turned on? Do you have display_errors turned on? I'm guessing not or you probably wouldn't see a white page. You'd see the errors.


can't pull values from table but insert is ok - El Forum - 11-01-2012

[eluser]teddy[/eluser]
@CroNiX: thank you for your reply

Yes of course I had declare construct function in HomePage controller but nothing happen, and how can I display_errors turn on or php error reporting turned on in codeigniter

Code:
function __construct()
{

parent::__construct();  
$this->load->model('common_model');
  
}



can't pull values from table but insert is ok - El Forum - 11-01-2012

[eluser]teddy[/eluser]
finally, I found that my password connect to database is wrong, and I connected to database is ok.


can't pull values from table but insert is ok - El Forum - 11-01-2012

[eluser]CroNiX[/eluser]
How were you inserting if the password was wrong?