I would like some help with my connect class.This class is created by me it is my way of thinking so i would like to know why this class dossent get my variables and connect proprely to mysql.
the code
<?php /**
*
Exp:Connect to database in oop style
@params host dbname username password
*/
class Connect
{
//private only available forthe current class
private $host=null;
private $dbname = null;
private $username = null;
private $password = null;
function __construct($host,$dbname,$username,$password)
{
$this->host = $host;
$this->dbname = $dbname;
$this->username = $username;
$this->password = $password;
$host = "localhost";
$dbname = "testoop";
$username = "root";
$password = "";
}
function connect(){
try {
$conn = new PDO('mysql:host='.$this->host.';dbname='.$this->dbname, $this->username, $this->password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'Unable to connect';
}
}
}
$con = new Connect();
$con->connect();
?>
Thank you for your time and any advices regarding security