Sorry, I posted the wrong code:
Here is the class file:
<?
class mysql {
var $host;
var $database;
var $username;
var $password;
function mysql()
{
mysql_connect($this->host, $this->username, $this->password)
or die("<b>Could not connect to MySQL server:</b><br>" . mysql_error());
mysql_select_db($this->database)
or die("<b>Could not select MySQL database:</b><br>" . mysql_error());
return;
}
}
?>
Here is the file that sets the variables:
<?
include('mysql.php');
$test = new mysql;
$test->host = "localhost234";
$test->username = "root";
$test->password = "";
$test->database = "TEST";
?>
I put the wrong values for the variables to see if the error handling worked and if the function works.
When I run the page that calls the class it gives me this error:
Could not select MySQL database:
No Database Selected
The mysql_connect function does not seem to be working in the class.
And yes, MySQL works on my computer. I just can't seem to get it to work with this class.
What am I doing wrong?