0
我有一個連接到數據庫的文件。當我在localhost上運行它時效果很好,但是由於將它放置在線上,連接失敗。我的代碼是;PDO數據庫連接失敗
<?php
// List of events
$json = array();
// Query that retrieves events
$requete = "SELECT * FROM rota ORDER BY id";
// connection to the database
try {
$bdd = new PDO('mysql:host=IllusionsMembers.db.12196899.hostedresource.com;dbname=IllusionsMembers', 'IllusionsMembers', 'password');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// Execute the query
$resultat = $bdd->query($requete) or die(print_r($bdd->errorInfo()));
// sending the encoded result to success page
echo json_encode($resultat->fetchAll(PDO::FETCH_ASSOC));
?>
我有可能是主機名導致錯誤,因爲我從來沒有在任何其他項目中使用的任何其他名稱APRT從localhost
的感覺。
this:'連接失敗:找不到驅動程序'。 – Braydos1986
從您的php.ini中取消註釋extension = php_pdo_mysql.dll,然後重新啓動Apache。 –