创建pdo对象时出现Connection failed: could not find driver解决思路

WBOY
Release: 2016-06-13 12:15:11
Original
1602 people have browsed it

创建pdo对象时出现Connection failed: could not find driver
创建pdo对象的代码:

<br /><?php<br />	try{<br />		$dbh=new PDO("mysql:host=localhost;dbname=name","user","password");<br />	}catch(PDOException $e){<br />		echo 'Connection failed: '.$e->getMessage();<br />	}<br />?><br />
Copy after login


php.ini配置文件中都已经改成:
<br />extension=php_mysql.dll<br />extension=php_pdo.dll<br />extension=php_pdo_mysql.dll<br />
Copy after login



------解决思路----------------------
1、检查 php.ini 是否生效(你修改的文件位置是否正确)
2、php5.3 起已经没有了 php_pdo.dll(pdo 对象已经内置),如果 extension=php_pdo.dll 则会因加载失败而导致 pdo_mysql 失效
3、php5.2 及以前的 pdo 极不稳定,不建议使用
------解决思路----------------------
<br /><?php<br />phpinfo();<br />?><br />
Copy after login


看看有没有PDO。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template