Working on a zen-cart. I am trying to modify the zen_get_categories_image function to provide a random product image from within that category if no category image exists. I thought I had it but although no errors, it is not working as I expected. Any obvious errors?? I think my problem is with the "If Null" part.
function zen_get_categories_image($what_am_i) {
global $db;
$the_categories_image_query= "select categories_image from " . TABLE_CATEGORIES . " where categories_id= '" . $what_am_i . "'";
$the_products_category = $db->Execute($the_categories_image_query);
if ($the_products_category->fields['categories_image'] !=NULL){
return $the_products_category->fields['categories_image'];
} else {
$random_product_query= "select products_image from " . TABLE_PRODUCTS . " where master_categories_id= '" . $what_am_i . "'";
$random_product_raw = $db->Execute($random_product_query);
$random_product_image_rand = array_rand($random_product_raw,1);
$the_products_category->fields['categories_image'] = $random_product_image_rand[0];
return $the_products_category->fields['categories_image'];
}
}