I am really sorry not to include the code of the opendb() function. What the function does is opening a connection to the database. I am including the code below, in case you face any more problem please let me know.

Code: php
function opendb()
 {
   global $server,$user,$pass,$db;
   mysql_connect($server,$user,$pass);
   mysql_select_db($db);
 }
 
 function closedb()
 {
   mysql_close();
 }