在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  PHP  數(shù)據(jù)庫/ PHP無法修改數(shù)據(jù)庫數(shù)據(jù)

PHP無法修改數(shù)據(jù)庫數(shù)據(jù)

卡在ERROR報錯一整天了,求大佬們幫幫忙
核心報錯如圖所示:
圖片描述

完整代碼在此:

<?php
header('Content-Type:textml;charset=utf-8');
$username='游客';
//獲取用戶輸入的賬號和密碼并連接數(shù)據(jù)庫
$account=$_POST['account'];
$password=$_POST['password'];
$db=new mysqli('localhost','root','12345678','newsmanage');
//查詢數(shù)據(jù)庫是否已經(jīng)有相同賬號
$query1=$db->prepare("SELECT account FROM user");
$query1->bind_result($theaccount);
$query1->execute();
while($query1->fetch()) {
    if ($account == $theaccount) {
        echo '<script>alert("該賬號已被注冊!");location.href="register.html"</script>';
        exit();
    }
}
//將用戶輸入的賬號和密碼寫入數(shù)據(jù)庫
$add=$db->prepare("INSERT INTO user VALUES (null,'general',null,?,?)");
$add->bind_param('ss',$account, $password);
$add->execute();
//數(shù)據(jù)庫對添加的新用戶自動生成唯一ID,查尋此ID并賦值變量
$query2=$db->prepare("SELECT userid FROM user WHERE account='$account'");
$query2->bind_result($userid);
$query2->execute();
$query2->fetch();
//用username變量修改數(shù)據(jù)表中的數(shù)據(jù)
$edit=$db->prepare("UPDATE user SET username=? WHERE account=?");
$edit->bind_param('ss',$username,$account);
$edit->execute();
//報錯提示:Call to a member function bind_param() on boolean in
echo '<script>alert("恭喜您,注冊成功!");location.href="../login/login.html"</script>';
回答
編輯回答
痞性

錯誤信息已經(jīng)說的很清楚了,說你對一個bool值使用了成員函數(shù)。
這個錯誤信息說明你的$db->prepare()方法執(zhí)行失敗了,返回了false,而不是mysqli_stmt對象。
請確認$db是否正確連接,prepare方法中的sql所涉及的表字段名是否有誤。以及其他我暫時想不到的問題。。。

2017年11月25日 23:24