![]() |
[SOLVED] Message: 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 Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: [SOLVED] Message: Object of class stdClass could not be converted to string (/showthread.php?tid=40506) |
[SOLVED] Message: Object of class stdClass could not be converted to string - El Forum - 04-11-2011 [eluser]Roy MJ[/eluser] I was trying to get once field value from database and error is showing saying cant convert to string. The controller is as follows : Code: function storage($selected_stack=''){ Model is as follows: Code: function getstack($selected_stack) View Code: <?php echo $stackname?> error: Code: A PHP Error was encountered [SOLVED] Message: Object of class stdClass could not be converted to string - El Forum - 04-11-2011 [eluser]Roy MJ[/eluser] When i do this its printing the contents, Code: <?php print_r($stackname)?> But how can i get the Travel alone to be displayed on the screen..?? [SOLVED] Message: Object of class stdClass could not be converted to string - El Forum - 04-11-2011 [eluser]mihaibaboi[/eluser] [quote author="Roy MJ" date="1302530755"] But how can i get the Travel alone to be displayed on the screen..??[/quote] Code: print_r($stackname->stack); Or Code: print_r($stackname->getStack()); If the object has setter and getter methods. [SOLVED] Message: Object of class stdClass could not be converted to string - El Forum - 04-11-2011 [eluser]Josh Holloway[/eluser] In your view you need to do: Code: <?php echo $stackname->stack; ?> [SOLVED] Message: Object of class stdClass could not be converted to string - El Forum - 04-11-2011 [eluser]Roy MJ[/eluser] Both Code: echo $stackname->stack; Code: print_r($stackname->stack); worked for me.. thankyou guys....... |