Coldfusion/MySql error - Division by zero is not possible
Posted on 2013-06-27
My template has a Coldfusion variable "priceperfoot" that is calculated by dividing the "price" by "totalfinishedsqft" for a home. In the database the totalfinishedsqft field can be null, 0, or a number greater than 0. If a record has null or 0 totalfinishedsqft then I get the error Division by zero is not possible, if it has a number greater than 0, it works fine. Can someone look at my code below and tell me where the error is? Or is there a better way of handling this? Thanks!
<cfif Len(trim(TotalFinishedSQFT)) GT 0>
<cfset priceperfoot = #Price# / #TotalFinishedSQFT#>