No, you wrote $count;
outside the loop, this can generate an error, change it with $count = 0;
and inside the loop place $count++;
just as in my previous example, if you do this it will start to work in the correct way.
Quick example:
<?php
$count = 0;
$a = array('a','b','c','d');
foreach($a as $b)
{
$count++;
echo 'fotog'.$count;
}
?>