gpt4 book ai didi

php - mysqli_query 返回不满足条件

转载 作者:行者123 更新时间:2023-11-29 15:59:38 24 4
gpt4 key购买 nike

如果total_money,我应该完成以下条件在表total_balance中大于10对于确切的用户消息应该显示但不起作用

有任何语法或逻辑错误吗?怎么解决?

 <?php
$db = mysqli_connect('localhost', '********', '**********', '*********');

$user_check_query = "SELECT total_money FROM total_balance WHERE username = '" . $_SESSION['username'] . "' ";
$result = mysqli_query($db, $user_check_query);
$row = mysqli_fetch_array($result);

if($result >10){
echo "Enough";
} else {
echo "Not Enough Money";
}
?>

表: total_balance

 ID   username        total_money
+----+--------------+---------------+
|1 | John | 100 |
+----+--------------+---------------+
|2 | Alex | 10 |
+----+--------------+---------------+
|3 | Pani | 5 |
+----+--------------+---------------+

最佳答案

改变

if($result >10){
echo "Enough";
} else {
echo "Not Enough Money";
}

if($row['total_money']  >10){
echo "Enough";
} else {
echo "Not Enough Money";
}

关于php - mysqli_query 返回不满足条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56274873/

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