![]() |
Error on ternary expression - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Error on ternary expression (/showthread.php?tid=81299) |
Error on ternary expression - Tajar_Dobro - 02-14-2022 Hi all, i have some error regarding ternary expression, it displays me only the default picture even if you have saved the product pic. on view i have added this line <img src="<?php echo base_url(!empty($row['image']) ? $row['image'] :'uploads/product_image/default.jpg'); ?>" id="output" class="rounded-md mt-3"/> on model i get the product by id //get product by id public function get_product_by_id($id){ $query = $this->db->get_where('products', array('id' => $id)); return $result = $query->row_array(); } RE: Error on ternary expression - php_rocs - 02-14-2022 @Tajar_Dobro , Exactly what error message are you getting? What version of CI are you using? Does your queries work within the database (phpMyAdmin)? RE: Error on ternary expression - Tajar_Dobro - 02-15-2022 Hello, CI Version 3.1, The error im facing is that even if i have pic for the product, the default image appears. RE: Error on ternary expression - php_rocs - 02-15-2022 @Tajar_Dobro , Do you use XDebug? It may be a situation where the wrong $id is being used or a condition is being meet that is causing the default image to be used. Can you show us the actual code (controller and view)? |