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
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
