简体   繁体   English

布尔值错误-mysqli

[英]error in a boolean - mysqli

i get an error in this code (comment in the code): 我在此代码中出现错误(代码中的注释):

if (checkBd ($sql, $db, $valor, $codePass)){

    ($sql = $db->prepare("UPDATE users SET activation = ? WHERE activationLink=?"));

    $valor="1";
    $sql->bind_param('is', $valor, $codePass);

    $sql->execute();

    $sql->bind_result($valor, $codePass); //Warning: mysqli_stmt::bind_result() [mysqli-stmt.bind-result]: Number of bind variables doesn't match number of fields in prepared statement 

    if ($sql->fetch()) {
        header("location: index.php");
        return true;
    }
    else {
        echo "no";
        return false;
    }
$sql->close();
$db->close();
}

what is the possible problem in the script? 脚本中可能存在什么问题? an another question, is this way correct to update a boolean? 另一个问题,以这种方式更新布尔值正确吗?

thanks 谢谢

I cannot retrieve a result from an UPDATE query. 我无法从UPDATE查询中检索结果。

solved with 解决了

    if (checkBd ($sql, $db, $codePass)){

    $valor=1;
    ($sql = $db->prepare("UPDATE users SET activation=? WHERE activationLink=?"));

    $sql->bind_param('is', $valor, $codePass);

    $sql->execute();
    header("location: index.php");
    return true;
}
else {
    echo "no";
    return false;
}
$sql->close();
$db->close();

Remove the quotes around your variables as they're not needed. 删除不需要的变量周围的引号。

If $valor is = 1 always you probably want to pass it as an integer. 如果$ valor = = 1,则始终可能希望将其作为整数传递。

$sql->bind_param('is', $valor, $codePass);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mysqli WHERE给出布尔错误 - Mysqli WHERE gives an boolean error PHP Mysqli错误:mysqli_query()期望参数1为mysqli,给定布尔值 - PHP Mysqli error: mysqli_query() expects parameter 1 to be mysqli, boolean given PHP mysqli prepare语句bind_param布尔错误 - PHP mysqli prepare statement bind_param boolean error 收到错误消息:警告:mysqli_fetch_array()期望参数1为mysqli_result,布尔值在 - Getting error: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in mysqli_fetch_array()错误期望参数1为mysqli_result,布尔值 - mysqli_fetch_array() error expects parameter 1 to be mysqli_result, boolean 我的 sql 查询是对还是错? 它向我显示错误,如警告:mysqli_num_rows() 期望参数 1 为 mysqli_result, boolean - My sql query is right or wrong ? It showing me error like Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean 使用PHP的MySQLi登录表单-致命错误:未捕获的错误:在布尔值上调用成员函数close() - MySQLi Login Form with PHP - Fatal error: Uncaught Error: Call to a member function close() on boolean MySQLI错误mysqli_connect - MySQLI error mysqli_connect 为什么 Query 会产生这个错误:mysqli_fetch_array() 期望参数 1 是 mysqli_result,布尔值在第 24 行的 storagelog.php 中给出 - Why does Query produce this error: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in storagelog.php on line 24 如何在PHP中使用mysqli检索布尔变量? - How to retrieve boolean variable using mysqli in php?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM