Works fine for me. I mean you have tons of other issues in this code and its pretty twisted up, but there is no issue with the ceil() call.
Perhaps you should start by reading this documentation: http://php.ca/manual/en/language.functions.php
. It should give you an idea of how to properly call functions.