count(): Parameter must be an array or an object that implements Countable error in php

This is because you are counting on ‘NULL’, Try it like this:

.
.
.
else
{
    $cart = [];
}
Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)