INSERT query produces quot;Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean givenquot;(INSERT 查询产生“警告:mysqli_num_rows() 期望参数 1 为 mysqli_result,给定布尔值)
问题描述
我对收到以下消息的原因感到困惑:
I am confused about why I am received the following message:
mysqli_num_rows() 期望参数 1 为 mysqli_result,给定布尔值
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
这个问题与之前的查询不同,因为我的查询实际上正确执行(确实已将值输入到数据库中).所以,我希望 MySQL 返回一个结果集而不是一个布尔值.
This question is different from previous queries because my query actually executes correctly (values were indeed entered into the database). So, I would expect MySQL to return a result set and NOT A BOOLIAN.
以下是我的功能:
function join_main_newsletter($firstName = null, $email)
{
global $dbc;
$valuesEntered = "values entered";
$insert = "INSERT INTO newsletter (first_name, email ) VALUES ('name', 'testemail@yahoo.com')";
$R3 = mysqli_query($dbc, $insert) or trigger_error("Query Failed! SQL: $sql - Error: " . mysqli_error(db_conx), E_USER_ERROR);
if (mysqli_num_rows($R3) == 1) {
return $valueentered;
} else {
}
}
这是错误的部分结果:
[valuesEntered] => values entered
[insert] => INSERT INTO newsletter (first_name, email )
VALUES ('name', 'testemail@yahoo.com')
[R3] => 1
推荐答案
mysqli_num_rows()
函数返回结果集中的行数.对于插入、更新和删除使用 mysqli_affected_rows
The mysqli_num_rows()
function returns the number of rows in a result set. For insert, update and delete use mysqli_affected_rows
这篇关于INSERT 查询产生“警告:mysqli_num_rows() 期望参数 1 为 mysqli_result,给定布尔值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:INSERT 查询产生“警告:mysqli_num_rows() 期望参数 1 为 mysqli_result,给定布尔值"
基础教程推荐
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在多维数组中查找最大值 2021-01-01