Names can't contain spaces, use camelCase names instead:
$categories = get the category($post->ID);
Becomes
$categories = getTheCategory($post->ID);
You can use underscores insead, but that's pretty old school these days:
$categories = get_the_category($post->ID);