you have to put the call to the database before the title tag to have the $rec[] array filled, once thats done you should be ok.