Drezard Posted November 20, 2007 Share Posted November 20, 2007 So, I created this script to connect to my database. Except for some reason its giving me a: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\project\extensions\includes\database.class.php on line 34 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\project\extensions\includes\database.class.php on line 36 Heres the code: class database { // set a few quick configuration settings: public $database_host = 'localhost'; // this setting selects the host that the database runs on public $database_username = '********'; // this setting selects the username that is used to login to the database public $database_password = '********'; // this setting selects the password that is used to login to the database public $database_database = 'ws_network'; // this setting chooses which database to select when connecting function database_connect() { $database_connection = mysql_connect($this->database_host, $this->database_username, $this->database_password); mysql_select_db($this->database_database, $this->database_connection); } } $class_database = new database; $class_database->database_connect(); I don't understand. Its all correct. Can someone please help me? Daniel Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 20, 2007 Share Posted November 20, 2007 <? class database { // set a few quick configuration settings: public $database_host = 'localhost'; // this setting selects the host that the database runs on public $database_username = 'P3t3rp4n'; // this setting selects the username that is used to login to the database public $database_password = 'T3l3visi0n'; // this setting selects the password that is used to login to the database public $database_database = 'ws_network'; // this setting chooses which database to select when connecting function database_connect() { $database_connection = mysql_connect($this->database_host, $this->database_username, $this->database_password); mysql_select_db($this->database_database, $database_connection); } } $class_database = new database; $class_database->database_connect(); try Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2007 Share Posted November 20, 2007 The error message indicates that the three connection detail variables don't have any value at the time the mysql_connect() function was called. I would guess that you are using PHP4. The "public" keyword being used to define those variables is only valid in PHP5. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.