2011-06-07 32 views
-1

可能重複:在查詢
SQLite database path not working錯誤SQLite數據庫與PHP中使用時

sqlite_query() [function.sqlite-query]: no such table: friends in D:\wamp\www\sqllite\index.php on line 11 

錯誤:SQL邏輯錯誤或丟失的數據庫

i am facing with this error. the data base ios connected correct.but it shows that no table 
my source code of php is this 

$db = "testdb.db"; 

echo $db; 
$handle = sqlite_open($db) or die("Could not open database".sqlite_error_string(sqlite_last_error($handle))); 

$query = ("SELECT * FROM friends"); 
$result = sqlite_query($handle,$query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle))); 
if (sqlite_num_rows($result) > 0) { 
    while($row = sqlite_fetch_array($result)) { 
     echo $row[0]; 
     echo $row[1]; 
     echo $row[2]; 
    } 
} 


sqlite_close($handle); 
?> 

和我的數據庫文件源代碼是它的名字是testdb.db

$dbhandle = sqlite_open('db/test.db', 0666, $error); 
if (!$dbhandle) die ($error); 

$stm = "CREATE TABLE Friends(Id integer PRIMARY KEY," . 
     "Name text UNIQUE NOT NULL, Sex text CHECK(Sex IN ('M', 'F')))"; 
$ok = sqlite_exec($dbhandle, $stm, $error); 

if (!$ok) 
    die("Cannot execute query. $error"); 

echo "Database Friends created successfully"; 

sqlite_close($dbhandle); 

回答

0

表的朋友們!=朋友

檢查:-)

+0

日Thnx交配對其做 – 2011-11-16 13:54:25