How I resolved my simple PHP math error
Nov 7, 2020
I wish I had someone else to look over my code!
I had two fields: one was null and the other was not. I used the intval() function to convert the values to “0” as needed, so I could add them together.
Do you see the error?
$good_rating_count = intval($entries['good_rating_count']);
$bad_rating_count = intval($entries['bad_rating_count']);
$total_rating_count = $good_rating_count + bad_rating_count;
The solution: I forgot the “$” in
$total_rating_count = $good_rating_count + $bad_rating_count;
Sometimes you just need another set of eyes to figure out the simplest of issues 😏.