Page 1 of 1

How can I save a dbhandle in an object?

Posted: Sat Mar 19, 2005 6:24 pm
by zylinder
Hi everybody!

I want to save a dbhandle in an object. My first thought was:

Code: Select all

$this->dbh = @mysql_connect($host, $user, $pw) or print mysql_error();
But when I want to close the connection the following code produces an error.

Code: Select all

mysql_close($this->dbh)
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource

I don't get it?
var_dump() shows that the var dbh is a resource ???

Thanx for your help

Posted: Sat Mar 19, 2005 8:52 pm
by feyd
where and when do you call close on it?

For future reference, use

Code: Select all

when you post php code.