Coding a forum is a massive work, and should only be undertaken under two circumstances really:
You have an enormous amount of free time, but no particular need for a forum that is tailored exactly to your requirements, and are willing to learn.
You have a large amount of time to give to it, and you desperately need a forum other than the excellent http://www.phpbb.com or vBulletin, and have been PHP'ing for a while now...
Other than that, it's really too difficult.
Due to a very specific problem with PHPBB (it doesn't fit with my site, and the PM'ing system isn't moderatable, which is needed for a site primarily catering to minors), I've had to start writing my own, which is causing all sorts of problems, what with marking things unread, with checking user input, with displaying posts carefully, with being secure, etc etc. I spent a whole day just getting the front page to look right. It's quite fun though!