Welcome Guest, Not a member yet? Register   Sign In
Severity: 4096 Message: Object of class CI_DB_mysql_result could not be converted to string
#1

[eluser]kazza[/eluser]
Hi everyone Smile

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 Smile

model...
Code:
[color=blue]function [/color]getAll()
  {
   $sql = $this->db->get('pages');
   $this->db->select('title');
   $this->db->from('pages');
   $this->db->where('id');
   $sql = $this->db->get();
   if($sql->num_rows() > 0)
   {
    foreach($sql->result() as $rows)
    {
     $data[] = $rows;
    }
    return $data;
   }
  }

view...

Code:
<?php echo $query = $this->db->query("SELECT title, content, displaypage, image_lower, image_upper FROM pages WHERE displaypage =  'contact'");

  foreach ($query->result() as $row)
  {
        ?>
            
            <div id="content_txt_boxes" >
            &lt;?php echo "<img src='$row-&gt;image_upper' />" ?&gt;
            <br />
            <strong>&lt;?php echo $row->title; ?&gt;</strong>
            <br />
            <br />
     &lt;?php echo $row->content;?&gt;
                    <br /><br />
                    &lt;?php echo "<img src='$row-&gt;image_lower'></div>
   &lt;?php
  }

is it also worth mentioning that all the data is displayed how and where i want it, but also includes the unwanted error msg
#2

[eluser]CroNiX[/eluser]
Take a look at this line:
Code:
&lt;?php echo "<img src='$row-&gt;image_lower'></div>
There is no closing double quote, the $row variable is enclosed in single quotes, and there isn't a closing php tag...
#3

[eluser]kazza[/eluser]
Thanks for the help - i tried a few things

[code] &lt;?php echo "<img src='$row-&gt;image_lower'
#4

[eluser]kazza[/eluser]
Thanks for the help - i tried a few things

[code] &lt;?php echo "<img src='$row-&gt;image_lower'
#5

[eluser]CroNiX[/eluser]
I would write it as:
Code:
&lt;?php echo '<img src="' . $row-&gt;image_lower . '" alt="" /></div>'; ?&gt;
#6

[eluser]kazza[/eluser]
Smile that maintains the pretty but still has the error.... my tiny brain hurts
#7

[eluser]vbsaltydog[/eluser]
Code:
&lt;?php var_dump($row); ?&gt;
#8

[eluser]CroNiX[/eluser]
Now compare that to the other image you are outputting...
#9

[eluser]kazza[/eluser]
[quote author="vbsaltydog" date="1327034883"]
Code:
&lt;?php var_dump($row); ?&gt;
[/quote]

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)
#10

[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.




Theme © iAndrew 2016 - Forum software by © MyBB