Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001011

[PHP-DB] Is there a way I can check if there are any usable mysql connections? From: Trond Erling Hundal (webmaster <email protected>)
Date: 01/03/01

I am having trouble with some classes I am writing on.
I am creating a set of classes to show a special portion of our web site`s
newsarticles.

The problem occours when I use a search class that scans through the
articles for a spesific
word or phrase.

The search class has a bundle of functions to search generete next/prev and
format the results correctly.
The search class is an extension of another class that handles the mysql
connection.

I suspect that the problem is that each time I search, the class reconnects
and selects the db.

When I try to search a couple of times.. I suddenly get problems on my main
site, some of the news cannot be shown.
For some time ago I had the same trouble when I used a presistant connection
to MySQL.
I thought I had solved this problem now, but I was proven wrong.

Here is the sql logon function:

function sql_logon($H, $U, $P) {
   // link to mYsql
$this->linkid = mysql_connect($this->H, $this->U, $this->P) ;

if (!$this->linkid) {

        $this->error = "Kunne ikke logge inn på databasen" ;
        $this->err_no = 1 ;
        return ;
}

// select database

  $result=mysql_select_db($this->sqldb,$this->linkid);
   if (!$result) // unable to select db
     {
      $this->err= mysql_error();
      $this->err_no=5;
      return;
     }
  } // end sql_logon function.

And in the search class I use:

$this->sql_logon($H, $U, $P) ;

Is there a way to "check" if there already is a connection to MySQL that can
be used to perform the search?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>