MySQLi stmt num_rows在服务器上返回0。在沼泽上工作很好

时间:2019-01-15 10:04:40

标签: php mysql

这是麻烦的代码

$stmt = $conn->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
    // Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
    $stmt->bind_param('s', $_POST['username']);
    $stmt->execute();
    $stmt->store_result();
    // Store the result so we can check if the account exists in the database.
    if ($stmt->num_rows > 0) {

1 个答案:

答案 0 :(得分:0)

$stmt = $conn->prepare('SELECT id, password FROM accounts WHERE username = ?');
    // Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
    $stmt->bind_param('s', $_POST['username']);
    $stmt->execute();

您错误地关闭了一个括号,并且有一个多余的花括号。