问题
And this is my code:
$q = "SELECT * FROM `my___passloging` WHERE `puser` = ? AND `ppass` = ?";
$procces = $this->db->prepare($q);
$procces->bind_result("ss", $user, $pass);
回答1:
You never executed your query.
$procces = $this->db->prepare($q);
$procces->execute(); // this part
$procces->bind_result("ss", $user, $pass);
Example from the manual:
/* prepare statement */
if ($stmt = $mysqli->prepare("SELECT Code, Name FROM Country ORDER BY Name LIMIT 5")) {
$stmt->execute();
/* bind variables to prepared statement */
$stmt->bind_result($col1, $col2);
- Unless you want to
bind_param()
instead of usingbind_result()
, to which you still need to execute that statement.
Example from the manual:
/* create a prepared statement */
if ($stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) {
/* bind parameters for markers */
$stmt->bind_param("s", $city);
/* execute query */
$stmt->execute();
/* bind result variables */
$stmt->bind_result($district);
References:
- http://php.net/manual/en/mysqli-stmt.bind-result.php
- http://php.net/manual/en/mysqli.prepare.php
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.
来源:https://stackoverflow.com/questions/30867385/i-want-to-make-a-log-in-page-using-mysqli-and-i-get-this-error-cannot-pass-para