开发者

error in SQLite database when using with php [duplicate]

开发者 https://www.devze.com 2023-03-11 18:11 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: SQLite database path not working
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

SQLite database path not working

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

Error in query: SQL logic error or missing database

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);
?>

and the my databas file source code is this its name is 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);


table friends != Friends

check it :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消