PHP中的致命错误SQLite3 :: query()

时间:2015-12-11 06:55:18

标签: php sqlite

当我尝试使用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代码。哪个是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 个答案:

答案 0 :(得分:0)

您应该知道为什么要创建$db对象。正确使用它而不是静态调用SQLite3::query(这不是一个静态函数)。

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

请参阅此处的示例以在SQLite3 http://php.net/manual/en/sqlite3.query.php

中运行查询