gpt4 book ai didi

php - MySQL 查询总是得到相同的结果

转载 作者:行者123 更新时间:2023-11-29 12:48:55 24 4
gpt4 key购买 nike

我正在尝试为我的“客户”做一些验证。客户输入他的 ID,然后弹出一个窗口警报,说明他/她已注册(并且已付款)或未注册。

但是,它总是返回“Inscrição feita e paga!” (铭文并付费!)

<?php

include("./config.php");

$BI = $_POST['BI'];

$query = mysql_query ("SELECT id_atleta from atleta where num_cidadao = '$BI'");

if ($query)

{
$resultado = mysql_fetch_row($query);

$query2 = "SELECT * FROM inscricao WHERE atleta_id_atleta = '$resultado' AND data_pagamento!= '0000-00-00 00:00:00'";


if ($query2)

{

echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Inscrição feita e paga!')
window.location.href='';
</SCRIPT>");

}

else
{

echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Isncrição a aguardar pagamento!')
window.location.href='';
</SCRIPT>");

}

}
else
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Não existe nenhuma inscrição associada a este BI!')
window.location.href='';
</SCRIPT>");
}
?>

最佳答案

查看这段代码:

$query2 = "SELECT * FROM inscricao WHERE atleta_id_atleta = '$resultado' AND data_pagamento!= '0000-00-00 00:00:00'";
if ($query2)

您没有执行查询,您只是检查 $query2 (字符串)是否不为 false 或 null。因此,当然,您总是会得到 if($query2) 之后的任何内容。

关于php - MySQL 查询总是得到相同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25040022/

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