PHP&MySQL:mysqli_num_row()期望参数1是mysqli_test,布尔值给定我正在尝试集成HTML净化器http://htmlpurifier.org/若要筛选用户提交的数据,请执行以下错误。我在想怎样才能解决这个问题?我得到以下错误。on line 22: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given第22行是。if (mysqli_num_rows($dbc) == 0) {下面是php代码。if (isset($_POST['submitted'])) { // Handle the form.
require_once '../../htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
$config->set('HTML.Doctype', 'XHTML 1.0 Strict'); // replace with your doctype
$purifier = new HTMLPurifier($config);
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"SELECT users.*, profile.*
FROM users
INNER JOIN contact_info ON contact_info.user_id = users.user_id
WHERE users.user_id=3");
$about_me = mysqli_real_escape_string($mysqli, $purifier->purify($_POST['about_me']));
$interests = mysqli_real_escape_string($mysqli, $purifier->purify($_POST['interests']));if (mysqli_num_rows($dbc) == 0) {
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"INSERT INTO profile (user_id, about_me, interests)
VALUES ('$user_id', '$about_me', '$interests')");}if ($dbc == TRUE) {
$dbc = mysqli_query($mysqli,"UPDATE profile
SET about_me = '$about_me', interests = '$interests'
WHERE user_id = '$user_id'");
echo '<p class="changes-saved">Your changes have been saved!</p>';}if (!$dbc) {
// There was an error...do something about it here...
print mysqli_error($mysqli);
return;}}
2 回答
阿晨1998
TA贡献2037条经验 获得超6个赞
$dbc
SELECT users.*, profile.* --You do not join with profile anywhere. FROM users INNER JOIN contact_info ON contact_info.user_id = users.user_id WHERE users.user_id=3");
四季花海
TA贡献1811条经验 获得超5个赞
FALSE
if (!$dbc || mysqli_num_rows($dbc) == 0)
mysqli_num_rows
:
返回值
在成功时返回true,在失败时返回false。对于SELECT,显示,描述或解释mysqli_query()将返回一个结果对象。
添加回答
举报
0/150
提交
取消