gpt4 book ai didi

php - 在没有匹配行的情况下,MySQLi 查询返回值

转载 作者:行者123 更新时间:2023-11-30 21:39:37 25 4
gpt4 key购买 nike

<分区>

我有一个表 bank 如下:

|name|day|time|
|jack| 1 | 2 |

我需要检查 namedaytime。现在,即使我更改了 WHERE 条件参数的值,以至于找不到匹配的行,它仍然会打印“成功”。这里有什么问题?如果我的代码尝试在下面:

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM `bank` WHERE name='jack' AND day='1' AND time='2'";
$result = $conn->query($sql);

if ($result)
{
echo "success";
}
else
{
echo "0 results";
}
$conn->close();
?>

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