PHP表单和mysql查询不起作用

时间:2017-05-18 13:25:54

标签: php mysql forms

我有一张桌子,并尝试更新一个值。但现在工作。我在apache2 log中遇到错误:

  

尝试在第133行获取非对象的属性

这是我的代码:

<form id="unblock" method="POST">
<div class="input-field col s11">
    <i class="material-icons prefix">search</i>
    <input id="unlock" type="text" class="validate" name="unlock"> 
    <label for="unlock">Kullanıcı Adı</label>
</div>
<div class="input-field col s11">
<button class=" btn-flat waves-effect waves-light right" type="submit" name="btn_unlock">Remove Block
    <i class="material-icons right">send</i>
</button>
</div>
</form>
<?php 
if(isset($_POST['btn_unlock'])) {
$unlock_username = $_POST['unlock'];
$sql_unlock="UPDATE users SET tries='0' WHERE 
user='$unlock_username'";
if($result_unlock = $mysqli->query($sql_unlock)){
    if($result_unlock->num_rows > 0){     /*LINE 133 IS HERE */
        echo "OK";
        $result_unlock->free();
    } else {
        echo "<script>Materialize.toast('There is no such user', 2000, 'blue lighten-5') </script>";
    }
}
?>

0 个答案:

没有答案