That's because your query resulted in an error and the reason for that is that you took my example too literally.
but instead of me taking you by the hand every step of the way, you would benefit a lot from it, trying to figure out what the problem is yourself.
try to rewrite your code in such a way that you first check if the query was successful and if it's not that you output the error to the screen (or write it to a log file ... but simply outputting is easier for now) so you can see what goes wrong (in this case: what error mysql returned)
- php: mysql_result()
- php: mysql_error()
- mysql: date_format()
each of these topics contain examples that should get you on your way.