2015-12-11 70 views
-2

我得到了下面的錯誤,而我試圖讓使用SQLite3的致命錯誤的SQLite3 ::查詢()在PHP

Fatal error: Non-static method SQLite3::query() cannot be called statically in C:\xampp\htdocs\s\sqlite\forgot.php on line 16 

我嘗試使用sqlite3的製作登錄系統在PHP中PHP忘記密碼的頁面。我在整個登錄過程中都做了正確的操作,但是忘記密碼會讓我的頭髮變成灰色:/這是我忘記密碼的PHP代碼。這是Forget.php

<?php 

class MyDB extends SQLite3 
{ 
    function __construct() 
    { 
    $this->open('test.db'); 
    } 
} 
$db = new MyDB(); 
if(!$db) 
{ 
    echo $db->lastErrorMsg(); 
} else{ } 

$query = SQLite3::query($db, 'SELECT email, password FROM user LIMIT 25'); 
$result = sqlite_fetch_all($query, SQLITE_ASSOC); 
foreach ($result as $entry) { 
echo 'Email: ' . $entry['email'] . ' Password: ' . $entry['password0']; 
} 
?> 



<html> 

<head> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Forgot Password</title> 

</head> 

<body> 

<form action="" method="post"> 
     <h1> Forgot password!</h1> 
     <label> Enter Your Email ID : </label> 

     <input id="email" type="email" name="email" required=" " /> 

     <input id="button" type="submit" name="submit" value="Submit" /> 

    </form> 

</body> 

</html> 
+1

運行查詢你知道什麼是'static',對不對? –

回答

0

爲什麼你已經創建了$db對象你應該早就知道。正確使用,而不是靜態調用SQLite3::query(這不是靜態函數)。

$query = $db->query('SELECT email, password FROM user LIMIT 25'); 

在這裏看到的例子,在sqlite3的http://php.net/manual/en/sqlite3.query.php