This question already has an answer here:
on Control page:
on View Page:
Error is:Notice: Trying to get property of non-object in C:\wamp\www\phone\pages\init.php on line 22Can you fix it? I don't have any idea what happened. |
|||
| add comment |
marked as duplicate by tereško, Danack, andrewsi, Jim, Macduff Oct 15 at 8:42
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Check the manual for
mysql_fetch_object(). It returns an object, not an array of objects.I'm guessing you want something like this
Might I suggest you have a look at PDO. PDOStatement::fetchAll(PDO::FETCH_OBJ) does what you assumed mysql_fetch_object() to do | |||||
Your errorNotice: Trying to get property of non-object in C:\wamp\www\phone\pages\init.php on line 22 Your comment
@22 is
$sidemenu is not an object, and you are trying to access one of its properties.That is the reason for your error. | |||
| add comment |
$sidemenu is not an object, so you can't call methods on it. It is probably not being sent to your view, or $sidemenus is empty.
| |||||||||
|
or
then
|
$sidemenuis not an object.var_dump()it and see what it is. – alex May 5 '11 at 2:08<?php echo $sidemenu->mname."<br />";?>– Gerelt Od May 5 '11 at 2:11$menumight be an empty string. That would cause your$sidemenuto not be an object. – Chris Henry May 5 '11 at 2:13