The code uses the same search field to search for either the product name, description, full description, code/sku, and ID.
What version are you trying to apply the code too?
$total_products_in_search is returning zero, so the math is trying to divide by zero.
hth.