How I resolved my simple PHP math error

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 😏.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store