-1
一切正常,沒有任何地方的單個流,其殺死我:我的SQL/PHP/PDO:奇怪的錯誤
這是錯誤:
SQLSTATE [HY000] [14]無法打開數據庫文件
這是代碼:
<?php
$dsn = 'mysql:host=localhost;dbname=new_db';
$db = new PDO($dsn,'root');
和:
<?php
try {
require_once 'pdo_connect.php';
} catch (Exception $e) {
$error = $e->getMessage();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Database Connection with PDO</title>
<link href="../../styles/styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Connecting with PDO</h1>
<?php if ($db) {
echo "<p>Connection successful.</p>";
} elseif (isset($error)) {
echo "<p>$error</p>";
}
?>
</body>
</html>
xamp有什麼問題? ,我給每個文件夾任何人permision和根用戶az管理員全部
該數據庫是否將'new_db'存在嗎?你爲什麼不提交密碼? – Reeno 2014-12-07 11:51:15
是的,它沒有密碼 – Greatone 2014-12-07 11:57:01