Error on ternary expression |
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(); }
@Tajar_Dobro ,
Exactly what error message are you getting? What version of CI are you using? Does your queries work within the database (phpMyAdmin)?
Hello, CI Version 3.1,
The error im facing is that even if i have pic for the product, the default image appears.
@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)? |
Welcome Guest, Not a member yet? Register Sign In |