When I do a SQL search in phpMyAdmin (substituting the variable for the actual value) it returns the correct row number but when using PHP to return this value it always ret
When you use COUNT(*) you always get one row returned even if the count is zero.
COUNT(*)
You either:
count(*)
mysqli_num_rows()
.
$row = mysqli_fetch_assoc($query); echo $row['COUNT(`user_id`)'];