本文介紹了PDO:找不到驅動程序 php/mysql的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在連接到我擁有的網絡主機上的數據庫時遇到問題,我正在使用以下內容:
i'm having issues connecting to my database on a web host that I have, i'm using the following:
$dsn = 'mysql:host=mysql1.hosting.digiweb.ie;dbname=mydbname';
$user = 'myusername';
$password = 'mypassword';
根據網站:Host Name mysql1.hosting.digiweb.ie(ip地址)
According to the website: Host Name mysql1.hosting.digiweb.ie (ip address)
正如標題所說,我遇到了找不到驅動程序的錯誤,我是否錯誤地輸入了主機,我嘗試輸入上面的內容以及 IP 地址 - 謝謝!
as the title says i'm getting a could not find driver error, am i entering the host incorrectly i tried entering whats above and also the ip address - Thanks!
這是我所有的代碼
<?php
$dsn = 'mysql:host=localhost;dbname=';
$user = '';
$password = '';
try {
// Connect and create the PDO object
$dbh = new PDO($dsn, $user, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
echo 'Database connection failed - ';
echo $e->getMessage();
exit;
}
echo 'works';
?>
推薦答案
轉到你的 php.ini 文件并取消注釋這一行
go to your php.ini file and uncomment this line
extension=php_pdo_mysql.dll
然后重啟你的 apache
and then restart your apache
這篇關于PDO:找不到驅動程序 php/mysql的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!