gpt4 book ai didi

PHP Impact_rows 返回负数 1 (-1)

转载 作者:行者123 更新时间:2023-12-04 16:49:35 24 4
gpt4 key购买 nike

这很奇怪,查询执行得很好并将数据插入表中,但我受影响的行显示为负数而不是 1。有谁知道为什么会这样?

连接.php:

<?php
error_reporting(0);
$db = new mysqli('localhost', 'root', 'pass', 'db');
?>

这是主要代码:
<?php
include 'connect.php';
include 'blowfish.php';

if($_POST['email'] == true)
{
if($db -> connect_errno)
{
echo "Could not connect to the database, please try again later...";
}
else
{
$email = $_POST['email'];

$query = "SELECT id FROM users WHERE email = ?";
$statmnt = $db -> prepare($query);
$statmnt-> bind_param("s",$email);
$statmnt-> execute();
$statmnt-> bind_result($result);
$statmnt-> fetch();
$statmnt-> reset();
if($result)
{
$id = $result;
$result = "";

$randomString = generateRandomString(50); // Generate random string

$query = "UPDATE users SET emailString = ? WHERE id =?";
$statmnt= $db -> prepare($query);
$statmnt-> bind_param("si",$randomString,$id);
$statmnt-> execute();
$statmnt-> bind_result($result);
$statmnt-> fetch();
$statmnt-> reset();

$test = $db -> affected_rows;
echo $test;
}
else
{
echo "That Email Address is not registered...";
}
}
}
else
{
echo "No Email received...";
}

?>

$test 返回“-1”

最佳答案

你应该得到 affected_rows打电话之前的值(value)reset()close()功能在 $statmnt .

关于PHP Impact_rows 返回负数 1 (-1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25907097/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com