CodeIgniter Forums
4096 CI_DB_mysql_result could not be converted to string - 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: 4096 CI_DB_mysql_result could not be converted to string (/showthread.php?tid=23734)



4096 CI_DB_mysql_result could not be converted to string - El Forum - 10-20-2009

[eluser]Unknown[/eluser]
ERROR: 4096
MESSAGE: 4096 CI_DB_mysql_result could not be converted to string
LINE = '**'

CODE:
Code:
$varX = $this->input->post('param1', TRUE);
$varY = $this->input->post('param2', TRUE);
$varW = $this->functionA->getValue($varX);

**$varZ = $varW . $varY;          //line referenced in the error as the problem

$this->db->where('colX', $varX);
$this->db->where('colY', $varZ);
$query = $this->db->get('table1');

I'm sure there is a simple solution that I am missing here and after reading the:
..input->post
..forums
..CI user guide
..php concatenation, etc...

I still haven't found the answer and I'm sure it has something to do with the variable reference or retrieval.

I'm new to CI, thanks for the help.


4096 CI_DB_mysql_result could not be converted to string - El Forum - 10-20-2009

[eluser]pistolPete[/eluser]
Please use code tags!

Since you didn't post functionA, I have to guess it's returning a database result object, which you just can't concatenate with a string to another string.


4096 CI_DB_mysql_result could not be converted to string - El Forum - 10-20-2009

[eluser]Unknown[/eluser]
That is correct, the object returned from FUNCTION A is a database object. Based on your assessment, I made the changes below "Revised Code" and no longer getting the 4096. Thanks.

FUNCTION A
Code:
$this->db->select('columnF');
$this->db->where('varX', $varX);
$query = $this->db->get('table2');

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

REVISED CODE:
Code:
$varX = $this->input->post('param1', TRUE);
$varY = $this->input->post('param2', TRUE);
$varW = $this->functionA->getValue($varX);

**$varZ = $varW->row('colW') . $varY;          //CHANGED

$this->db->where('colX', $varX);
$this->db->where('colY', $varZ);
$query = $this->db->get('table1');