PDO:找不到驱动程序php/mysql [英] PDO: Could not find driver php/mysql

查看:301
本文介绍了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';

根据该网站:主机名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

然后重新启动

这篇关于PDO:找不到驱动程序php/mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆