How about this idea?
Create a single small PHP script that echoes the cart count.
That is all the script does.
Then, when you get that working, include it in the HTML of
anywhere you wish to display it.
The cart contains <?php include("count.php");?> items.
That way, you only code it one time and use it everywhere.