Given the code:
$counters = $db->query("SELECT COUNT(film_id) FROM review WHERE film_id = $film_id ");
I need to convert the object $counters into an integer. FYI: the query returns a single int i.e 4 (depending on the film_ID)
Give an alias to the column that stores the COUNT result then use it as you would use with any other SELECT query.
$counters = $db->query("SELECT COUNT(film_id) AS counter FROM review WHERE film_id = $film_id "); $counter = $counters->fetch_assoc(); echo $counter['counter'];
$counters is not the result string you assume, but a resource object.
My suggestion is to change the code as follows:
$res = $db->query("SELECT COUNT(film_id) as counter FROM review WHERE film_id = $film_id ");
$row = $res->fetch_assoc();
$counter = (int) $row["counter"];