If you are making a custom page, then you should be following a tutorial such as this one -
[HOW TO - vB4] Create your own vBulletin page. The above cannot be all of your code, because I can see it is in a vbulletin like page, so there much have been more to it than what you posted. You should post your page/php in php tags and then post your templates in html tags so that it is easier for us to read.