Hello, I connect to a bank, how would I connect with another, who has the same login and password inside the same server? follows my function:
function conectaBanco() {
$hostname='dbprovider.rede.local';
$username='root';
$password='8asd331221!';
try {
$dbh = new PDO("mysql:host=$hostname;dbname=Provider",$username,$password,
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
}
catch(PDOException $e) {
echo $e->getMessage();
}
}
In case like I do here to connect with the other bank, example I want to put
$dbh2 = new PDO("mysql:host=$hostname;dbname=Provider2",$username,$password,
But it did not work !!! Can someone help? the error is Uncaught Error: Call to a member function query () on null line 48 and in that line has
$dbh = conectaBanco();