SQLite3Stmt :: execute()需要0个参数,1给出错误?

时间:2018-02-03 19:52:06

标签: php sqlite login parameters

尝试运行以下PHP文件时出现以下错误:

SQLite3Stmt :: execute()需要0个参数,给定1个(第34行)

调用未定义的方法SQLite3Stmt :: fetch()(第36行)

 <!doctype html>
 <html>
 <head>
 <meta charset="utf-8">
 <title>Untitled Document</title>
 </head>

 <?php
 class MyDB extends SQLite3
  {
  function __construct()
  {
     $this->open('Users.db');
  }
  }

  $db = new MyDB();


 $email_address = $_POST['email_address'];
 $password = $_POST['password'];

 $email_address =($email_address);
 $password =($password);

 $email_address = intval($_POST["email_address"]);
 $password = intval($_POST["password"]);
 $sql = "SELECT * FROM user_info WHERE email_address='$email_address' AND 
 password='$password WHERE email_address=? AND where password=?'";


 $stmt = $db->prepare($sql);
 $stmt->bindParam(1, $email_address);
 $stmt->bindParam(2, $password);

 $result = $stmt->execute($sql);

 while($column = $stmt->fetch())
 {
 echo $column["email_address"];
 echo $column["password"];
 };


if($email_address==1){
  echo "<h1>Logged In</h1>";
 }; 

  ?>


 <body>
</body>
</html>

这是一个简单的登录页面,它连接到SQLite数据库,然后登录时返回。

1 个答案:

答案 0 :(得分:0)

错误信息非常简单。在不需要执行方法的情况下,您将为执行方法提供参数。

$stmt->execute();