开发者

error in a boolean - mysqli

开发者 https://www.devze.com 2023-02-18 07:38 出处:网络
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=?\"));

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";
开发者_JAVA百科    $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.

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.

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号