How to enable PDO on AppServ on windows?

时光毁灭记忆、已成空白 提交于 2019-12-12 07:27:27

问题


I am trying to create an app fir the first time using PDO and when i

try {
    $db = new PDO('mysql:host=localhost;dbname=DBname', 'user', 'pass');
} catch(PDOException $e){
    echo '<div class="errorMSG">Failed to connect to database. Please try to refresh this page in 1 minute. However, if you continue to see this message please contact your system administrator.</div>';
    echo '<br /><br />' . $e->getMessage();
    exit();

}

ofcourse i have change pass user and DBname to the correct once but i have get an error could not find driver

So with few searches i found out that i need to enable pdo_mysql but i can't seems to find out where do I do that and how? Can some one please help me with how to enable this and/or get this to work on my local machine. I have windows 7. I can't find where is my php.int is located.

Thanks :)


回答1:


Take a look into the PDO installation section of the PHP manual.

It depends on the OS of your machine. If you compile php yourself, and you wish to install the MySQL PDO driver, then you should add the --with-pdo-mysql config option before compiling PHP.

On a windows machine, just enable those two extensions...

extension=php_pdo.dll <- only if below php 5.3
extension=php_pdo_mysql.dll

...in your php.ini and restart your app server. The php.ini should usually be located in your php directory. Where it is located depends on where you've installed php.



来源:https://stackoverflow.com/questions/15231676/how-to-enable-pdo-on-appserv-on-windows

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