CodeIgniter Forums
Object of class stdClass 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 General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Object of class stdClass could not be converted to string (/showthread.php?tid=32810)



Object of class stdClass could not be converted to string - El Forum - 08-05-2010

[eluser]anpmtp[/eluser]
got me an error in my site...
Object of class stdClass could not be converted to string error occured when loading my page
this error occured in _serialize($data) function session.php library.
how can i solve ir


Object of class stdClass could not be converted to string - El Forum - 08-05-2010

[eluser]pickupman[/eluser]
Could you post some code? This type of error maybe from a library not being loaded, or you are passing the wrong data type to a function.


Object of class stdClass could not be converted to string - El Forum - 01-29-2011

[eluser]Unknown[/eluser]
array([0]=> stdClass Object ([id]=>1 [title]=>sabbir [content]=>My name is sabbir [date]=>2011-01-29))

A php error was encountered
massage: Object of class stdClass could not be converted to string

Code:
controller:
$data['query'] = $this->blog_model->get_blog();
$this->load->view('blogview',$data);
view:
<?php foreach($query as $value)
echo $value;
endforeach;
?>

there is no fetching problem.first line indicate that.


Object of class stdClass could not be converted to string - El Forum - 01-29-2011

[eluser]Cristian Gilè[/eluser]
Code:
<?php
foreach($query as $value)
{
      echo $value->id;
      echo $value->title;
      echo $value->content;
      echo $value->date;
}
?>
If $query returns a single result row and not an array of objects, you can avoid the foreach. Read the user guide.


Cristian Gilè