Well... your code really doesn't make any sense... I'm not sure what in blazes you're trying to do here, but I'm pretty sure it's ALL wrong.
1) if you're gonna use PDO, use it! -- and that means no screwing around with putting variables into the query strings -- that's prepare/execute's job... particularly if you're going to use "while".
2) If you are only using one result, select just that result not the entire bloody row.
3) Why are you making a single entry array, and then summing it?!? What possible purpose does that serve?!?
4) If all you are pulling is a sum, JOIN your results so it only needs ONE query.
5) $handeler? Is that some funky foreign spelling, or a typo?
I'm guessing wildly since I don't fully know your table structure, but that should go something more like this:
If all you're doing is grabbing the total of all products.pret_produs that are in the requested IP's cart.
$stmt = $handeler->prepare('
FROM products, cart
WHERE cart.ip_add = ?
AND cart.p_id = products.product_id
if ($sum = $stmt->fetch_column()) echo $sum;
else echo 'Error';
} // pret_total
NOT that I'd be using the IP address to track the user, since multiple users could come from the same IP... that's why you use the session hash or a random hash instead. (since I regenerate the session every pageload, I'd go with a random hash)
Basically though, stop brute forcing it and let SQL do its job, and stop putting variables into your query strings 2005 style.