Jump to content

Mysql_connect problem


Drezard

Recommended Posts

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

Link to comment
Share on other sites

<?
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.