PDO: Could not find driver php/mysql(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PDO:找不到驱动程序 php/mysql
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
