我使用MAMP已经有几个月了,但是今天我安装了AMPPS。
我将处理数据库,但它不起作用。我得到以下错误:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /Applications/AMPPS/www/functions.php:13 Stack trace: #0 /Applications/AMPPS/www/functions.php(13): PDO->__construct('mysql:host=loca...', 'root', 'usbw') #1 /Applications/AMPPS/www/functions.php(22): dbConn() #2 /Applications/AMPPS/www/test.php(18): imageDropdown('s') #3 {main} thrown in /Applications/AMPPS/www/functions.php on line 13代码:
// database connection
function dbConn() {
$username = "root";
$password = "usbw";
$dbh = new PDO(
'mysql:host=localhost; port=3306; dbname=webshop',
$username,
$password
);
return $dbh;
}
// dropdown met afbeeldingen
function imageDropdown($zoek) {
$dbh = dbConn();
$sth = $dbh -> prepare("
SELECT afbeelding
FROM Afbeelding
WHERE afbeelding LIKE '%:zoek%'
ORDER BY afbeelding
");
$sth -> bindValue(":zoek", $zoek, PDO::PARAM_STR);
$sth -> execute();
$result = $sth -> fetchAll(PDO::FETCH_ASSOC);
print("<pre>");
print_r($result);
print("</pre>");
}?>
(functions.php)
<?php
include "functions.php";
imageDropdown("s");
?>(test.php)
有一个司机失踪了,但我如何安装它?
我在麦克身上。
发布于 2013-11-11 19:53:06
在用户界面中- PHP选项卡- php扩展。检查是否启用了所需的扩展。比如pdo_mysql和pdo
https://stackoverflow.com/questions/19909692
复制相似问题