I find the error: could not find driver in the next script. I'm breaking my head over it now for some time now maybe you see the my fault.
This is my code:
class ConnectStation {
private $host = "localhost";
private $DatabaseType = "mysql";
private $database = array (
1 => "Database_one",
2 => "Database_two",
3 => "Database_true"
);
private $user1 = "MyUsername1";
private $pass1 = "MyPassword1";
private $user2 = "MyUsername2";
private $pass2 = "MyPassword2";
public function ConnectDB($user, $database){
if ($database==""){$database=1;}
try{
switch ($user){
case "ReadOnly":
$connection = new PDO("'".$this->DatabaseType.":host=".$this->host.";dbname=".$this->database[$database]."', '".$this->user1."', '".$this->pass1."'");
$connection->exec('SET CHARACTER SET utf8');
return $connection;
break;
case "Admin":
$connection = new PDO("'".$this->DatabaseType.":host=".$this->host.";dbname=".$this->database[$database]."', '".$this->user2."', '".$this->pass2."'");
$connection->exec('SET CHARACTER SET utf8');
return $connection;
break;
}
}
catch(PDOException $e){
echo $e->getMessage();
}
}
}
Oke so far the connection than the scrip i use for a query to send to the database. the code is like this:
$userCard = new ConnectStation;
$query = "SELECT username FROM users";
foreach ($this->ConnectDB('ReadOnly', 1)->query($query) as $row){
echo $row['username']."<br>";
}
Any help ore advise is welcome?