所以我正在为一个使用SQLite数据库和PHP的客户创建一个网站,以便在网站的某个页面上的表格中显示信息。运行页面时,我收到此错误。据我所知,它是由数据库和/或目录导致数据库没有正确的访问权限。我正在使用Charter Business Server,据我所知,我拥有正确的权限集。我试过谷歌搜索问题但发现没有任何帮助。
这是PHP代码:
<?php ini_set('display_errors', 1);
$dir = 'sqlite:/HTML/fsrd2.com/database/fsrd.db';
$database = new PDO($dir) or die("<tr><td>Cannot Open</td></tr>");
$query = "SELECT * FROM projects";
foreach($database->query($query) as $row)
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "</tr>";
}
?>
以下是完整的错误消息:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [14] unable to open database file' in /var/www/vhosts/12/234028/webspace/httpdocs/fsrd2.com/fsrd_projects.php:50 Stack trace: #0 /var/www/vhosts/12/234028/webspace/httpdocs/fsrd2.com/fsrd_projects.php(50): PDO->__construct('sqlite:/HTTP/fs...') #1 {main} thrown in /var/www/vhosts/12/234028/webspace/httpdocs/fsrd2.com/fsrd_projects.php on line 50