1
我試圖讓使用PHP的SQLite的連接。(我基本上是試圖通過Spiceworks還在數據庫這是我的系統上進行瀏覽。)SQLite和Spiceworks還在
我的PHP代碼工作正常,直到sqlite_open。但它不會超越SQLITE_OPEN。
問題是什麼?我如何糾正它? 我的代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<?php
// set path of database file
echo "Hello!";
$db = "C:\Program Files (x86)\Spiceworks\db\spiceworks_prod.db";
// open database file
$handle = sqlite_open($db) or die("Could not open database");
// generate query string
$query = "SELECT * FROM devices";
// execute query
$result = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
// if rows exist
if (sqlite_num_rows($result) > 0) {
// get each row as an array
// print values
echo "<table cellpadding=10 border=1>";
while($row = sqlite_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "</tr>";
}
echo "</table>";
}
// all done
// close database file
sqlite_close($handle);
?>
</body>
</html>
我也試過。它不起作用! – Anan
你能提供關於錯誤的更多信息嗎? – Flavio