11-07-2007, 06:19 AM
|
#4 (permalink)
|
|
The Contributor
Join Date: Sep 2007
Posts: 31
Thanks: 0
|
When you create an instance of your MySQL class, the connect() function should be called in your constructor. As for your database information, it's better to define them in your class. e.g.
PHP Code:
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASS", "");
And in your connect function:
PHP Code:
public function connectToMySQL() {
@mysql_connect(DB_HOST, DB_USER, DB_PASS) OR die("Cannot connect to MySQL server!");
mysql_select_db("login") OR die("Cannot select database!");
}
Then just call the connection in your constructor.
|
|
|
|