HTML encode messages.
Unset last nick if last line wasn't a message.
Open connection to database using charset utf8.