View Single Post
Old 11-07-2007, 06:19 AM   #4 (permalink)
daz
The Contributor
Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 31
Thanks: 0
daz is on a distinguished road
Default

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_HOSTDB_USERDB_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.
daz is offline  
Reply With Quote
The Following User Says Thank You to daz For This Useful Post:
codefreek (06-30-2008)