Hey,
First of all: My name is Fabian Golle and I'm new to this newsgroup. I'm 16
years old and from Hanau (Germany). I'm currently a student and in my
free-time I'm developing Web-Applications.
Here's my problem:
I've got a class for the Account-System of my Community. The Tables for the
Account-System are in a separate Database with own Login-Data.
There is a function, called connect, in the class which connects to the
Database.
public function connect() {
$this-link = mysql_connect(localhost, user, password, true);
mysql_select_db(micronax_mymicronax, $this-link);
}
$link is defined in class:
protected $link = false;
And now I'm able to use the connection in the other functions of the class
using $this-link:
$result = mysql_query($sql, $this-link) or die(mysql_error());
But now the problem is:
The connection shouldn't be used outside of the class. Also my thought was:
set $link to protected: No result. You can still access the Database outside
of the class. I also tried to close the connection via the
__desctruct-Function. No result.
I recognized the problem is: if no specific resource is given in
mysql_connect() the function uses automatically the last connection.
SO MY QUESTION IS NOW: HOW TO PREVENT THIS?
Please help me.
Greetings from Germany and happy easter,
Fabian Golle
Micronax.de