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
https://forums.phpfreaks.com/topic/78030-mysql_connect-problem/
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
https://forums.phpfreaks.com/topic/78030-mysql_connect-problem/#findComment-394931
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
https://forums.phpfreaks.com/topic/78030-mysql_connect-problem/#findComment-394956
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.