Welcome Guest, Not a member yet? Register   Sign In
Severity: 4096
#1

[eluser]oldrock[/eluser]
Hello Guys,

Im new with CI and i got little problem here. I've read the posts with the same error msg but i couldn't figure out whats the problem.


CODE:

Controller:

function add_player_details()
{

$this->load->model('admin_tool/addplayermodel');
$data['teams']=$this->addplayermodel->select_teams();
echo $data['teams'];
$this->load->helper(array('url','form'));
$this->load->view('admin-tool/add_player',$data);

}

Model:

function select_teams()
{
$query = $this->db->query("SELECT team FROM team");

if($query)
{
return $query;
}
else
{
return mysql_error();
}
}

And i get this error:
Severity: 4096

Message: Object of class CI_DB_mysql_result could not be converted to string

Filename: admin-tool1/login.php

Line Number: 68


Thanks in advance
#2

[eluser]eoinmcg[/eluser]
echo is for outputting strings, however, your model method 'select_teams()' returns a resource from the database. if you want to check it, for debugging purposes, try using var_dump() instead.

to display the results you'll need to do sth like this (in your view):

Code:
foreach($teams->result_array() as $team)
{
  echo $team['team'];
}
#3

[eluser]oldrock[/eluser]
Hi..,

that has done the job thank you very much for your help at right time.




Theme © iAndrew 2016 - Forum software by © MyBB