Hi, I'm a bit confused on what makes a connection persistant or dynamic. I have an example of my connection to my database, but not sure if it is persistant or not. Reason being is that my Hosting company says my scripts are possibly draining his resources and he's trying to get users to change their scripts to dynamic.

This is what I use now:

function db_connect()
{
   $result = @mysql_pconnect("localhost", "username", "password"); 
   if (!$result)
      return false;
   if (!@mysql_select_db("realm"))
      return false;

   return $result;
}

function db_result_to_array($result)
{
   $res_array = array();

   for ($count=0; $row = @mysql_fetch_array($result); $count++)
     $res_array[$count] = $row;

   return $res_array;
}

Is this what they're talking about? and if so, how do I just make it dynamic? 😕

Also, does this apply to the script calling up this function?

function get_videos($catid) // Get Video Titles
{
   // query database for the videos in a category
   if (!$catid || $catid=="")
     return false;

   $conn = db_connect();
   $query = "select * from rpg_videos where catid='$catid'";
   $result = @mysql_query($query);
   if (!$result)
     return false;
   $num_videos = @mysql_num_rows($result);
   if ($num_videos ==0)
      return false;
   $result = db_result_to_array($result);
   return $result;
}

Thanks for the help.

    Write a Reply...