Why this error appears stdClass::$pic_item? |
site/views/index.php
<?php foreach($pic as $pic_item): ?> <img src="<?php echo base_url('assets1/images/slider/'.$pic_item->pic_item );?>"> <?php endforeach;?> controllers/Cspages.php
How to handle this error message? A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$pic_item Filename: views/index.php Line Number: 214 Backtrace: File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\site\views\index.php Line: 214 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\site\controllers\Cspages.php Line: 31 Function: view File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\index.php Line: 315 Function: require_once http://localhost/masterlinkci2/assets1/images/slider/"> } views/index.php Line Number: 214 <img src="<?php echo base_url('assets1/images/slider/'.$pic_item->pic_item );?>">
" If I looks more intelligence please increase my reputation."
READ the error message! You are looping through a query result, assigning each to $pic_item. Then, in your view, you attempt to reference the pic_item property of $pic_item, and you are being told that $pic_item is not an object. Do a var_dump of $pic_item to see what it is.
You would think by now he would know how to use the CODE tags!
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I try to do the var_dump, the error remains the same as if nothing happens:
<?php foreach($pic as $pic_item): ?> <img src="<?php echo base_url('assets1/images/slider/'.$pic->pic_item );?>"> <?php var_dump($pic_item); ?> <?php endforeach;?> A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$pic_item Filename: views/index.php Line Number: 214
" If I looks more intelligence please increase my reputation."
READ the error message! You are looping through a query result, assigning each to $pic_item. Then, in your view, you attempt to reference the pic_item property of $pic_item, and you are being told that $pic_item is not an object. Do a var_dump of $pic_item to see what it is.
You'll need to do the var_dump before referencing $pic_item->pic_item. Your var_dump is not reached beecause of the error message.
var_dump is string(2) "18"
" If I looks more intelligence please increase my reputation."
Annnnnnnd ... there's your answer. $pic_item is a string, not an object with a nested pic_item property.
The code inside your loop only needs to be Code: <img src="<?php echo base_url('assets1/images/slider/'.$pic_item);?>">
A PHP Error was encountered
Severity: 4096 Message: Object of class stdClass could not be converted to string Filename: views/index.php Line Number: 213 Backtrace: File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\site\views\index.php Line: 213 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\site\controllers\Cspages.php Line: 32 Function: view File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\index.php Line: 315 Function: require_once Line 213: <img src="<?php echo base_url('assets1/images/slider/'.$pic_item);?>"> TABLE galleries_pictures 1 picture_unique_id int(11) 2 gallery_id int(3) 3 galleries_picture_name varchar(30)
" If I looks more intelligence please increase my reputation."
I finally get the answer but still cannot explain my own answer if anyone can help me explain this codes out:
<?php foreach($pic as $pic_item): ?> <img src="<?php echo base_url('assets1/images/slider/'.$pic_item->galleries_picture_name);?>"> <?php endforeach;?> First, do I really need the foreach loop? Second, why $pic_item->galleries_picture_name works?
" If I looks more intelligence please increase my reputation."
When you ask question on here if you have code you can use the buttons in the editor one is call php and code
Also might be best to watch some tutorials on you tube might learn some more stuff about codeigniter that way.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |