Severity: 4096 Message: Object of class 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: Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string (/showthread.php?tid=48522) Pages:
1
2
|
Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]kazza[/eluser] Hi everyone Im new to codeigniter ans was loving it...until this "Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string" I have read through the posts and looked at whats going on, tried loads of those tricks and still getting the above error. Any suggestions would be gratefully accepted model... Code: [color=blue]function [/color]getAll() view... Code: <?php echo $query = $this->db->query("SELECT title, content, displaypage, image_lower, image_upper FROM pages WHERE displaypage = 'contact'"); is it also worth mentioning that all the data is displayed how and where i want it, but also includes the unwanted error msg Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]CroNiX[/eluser] Take a look at this line: Code: <?php echo "<img src='$row->image_lower'></div> Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]kazza[/eluser] Thanks for the help - i tried a few things [code] <?php echo "<img src='$row->image_lower' Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]kazza[/eluser] Thanks for the help - i tried a few things [code] <?php echo "<img src='$row->image_lower' Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]CroNiX[/eluser] I would write it as: Code: <?php echo '<img src="' . $row->image_lower . '" alt="" /></div>'; ?> Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]kazza[/eluser] that maintains the pretty but still has the error.... my tiny brain hurts Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]vbsaltydog[/eluser] Code: <?php var_dump($row); ?> Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]CroNiX[/eluser] Now compare that to the other image you are outputting... Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]kazza[/eluser] [quote author="vbsaltydog" date="1327034883"] Code: <?php var_dump($row); ?> Code: object(stdClass)#17 (5) { ["title"]=> string(28) "Email [email protected]" ["content"]=> string(345) "While produce that is purchased in the supermarket has been in transit or cold-stored for days or weeks, produce that you purchase at your local farmers market has been picked within 24 hours of your purchase. This freshness not only affects the taste of your food, but the nutritional value which declines with time." ["displaypage"]=> string(7) "contact" ["image_lower"]=> string(0) "" ["image_upper"]=> string(44) Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string - El Forum - 01-19-2012 [eluser]vbsaltydog[/eluser] As you can see in the output of var_dump, your property is empty. FYI. You have bad code in your method and you are calling sql data in your view file which breaks the MVC design pattern. |