PDOexception - 'could not find driver'

99封情书 提交于 2019-12-11 04:47:17

问题


I woork on my local site with MAMP. Everything was going right till yesterday. Now, when I run my code, I get a : "Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'..." It seems that I have non installed driver but it worked well until this day. How can I fix this problem ?

Best, Newben


回答1:


I had a similar problem. Sfblaauw's solution didn't work but it helped me identify the problem. First I installed php5-mysql using MacPorts:

sudo port install php5-mysql

During installation, I got the following warning:

Your php.ini contains a line that will prevent php5-mysql and other PHP extensions from working. To fix this, edit /opt/local/etc/php5/php.ini and delete this line:

extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626"

I commented out the line and restarted Apache. Everything seems to work fine now.




回答2:


Have you installed MacPorts? If your answer is "yes" open your Shell and type:

  1. cd ~/
  2. sudo nano .profile
  3. change: export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    replace with: export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php/php5.3.6/bin/:$PATH

  4. close your Shell and re-open it

This is all. I found the solution here: thewebfactory



来源:https://stackoverflow.com/questions/10912040/pdoexception-could-not-find-driver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!