我有以下SQL数据库:CREATE TABLE IF NOT EXISTS `accounts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `password` varchar(255) NOT NULL, `email` varchar(100) NOT NULL, 'experience' enum('Beginner', 'Intermediate', 'Advanced) NULL, Default Beginner, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;INSERT INTO `accounts` (`id`, `username`, `password`, `email`, 'experience') VALUES (1, 'test', '$2y$10$SfhYIDtn.iOuCW7zfoFLuuZHX6lja4lF4XA4JqNmpiH/.P3zB8JCa', 'test@test.com');除此之外,我还有一个注册表单,该表单将使用注册表单将给定的值填充到数据库中。下面的HTML表单将作为更新表单:<div class="card bg-light"> <div class="register"> <h1>Update My Preferences</h1> <form action="update_preferences.php" method="post" autocomplete="off"> <div class="form-group input-group"> <select name="new_experience" class="form-control"> <option selected="">Change Investment Experience</option> <option>Beginner</option> <option>Intermediate</option> <option>Advanced</option> </select> </div> <!-- form-group end.// --> <label for="username"> <i class="fas fa-user"></i> </label> <input type="text" name="new_username" value="<?=$_SESSION['name']?>" id="username"> <label for="password"> <i class="fas fa-lock"></i> </label> <input type="password" name="new_password" placeholder="" value="" id="password"> <label for="email"> <i class="fas fa-envelope"></i> </label> <input type="email" name="new_email" value="<?=$email?>" id="email"> <input type="submit" value="Update"> </form> </div></div>我设法为其添加以下代码,update_preferences.php但随后陷入错误“无法准备语句!致命错误:在第71行的/home2/freemark/public_html/update_preferences.php中,对布尔值的成员函数close()进行调用”
2 回答
![?](http://img1.sycdn.imooc.com/533e564d0001308602000200-100-100.jpg)
慕容3067478
TA贡献1773条经验 获得超3个赞
不确定您坚持什么,但是查询多个字段更新看起来像这样:
$sql = "UPDATE accounts SET field1 = ?, field2 = ?, field3 = ? WHERE id = ?";
// binding values can be done something like
$stmt->bind_param('ssss', $variable1, $variable2, $variable3, $_SESSION['id']);
另外,请阅读此页面有关密码哈希的内容,并且永远不要存储纯密码。
- 2 回答
- 0 关注
- 108 浏览
添加回答
举报
0/150
提交
取消