-1

我正在尝试验证您何时获得相同的日期,相同的时间和相同的地点,它不会插入数据库中。如果 1 个实例返回 false,它只会插入数据库。

$res_date = $_POST['res_date'];
$res_venue = $_POST['res_venue'];
$res_dur = $_POST['res_duration'];

$qryjay = mysql_query("SELECT * FROM tbl_reservation WHERE res_date='$res_date' AND res_dur = '$res_dur' AND res_venue = '$res_venue'");        
if ((mysql_num_rows($qryjay) == $res_date) && ($qryjay == $res_dur) && ($qryjay) == $res_venue){
echo "<script language=javascript>alert('".$res_venue." is not available on ".$res_dur." on ".$res_date."!')</script>";
}
4

1 回答 1

0

尝试像这样修复您的代码:

<?
$res_date = mysql_real_escape_string($_POST['res_date']);
$res_venue = mysql_real_escape_string$_POST['res_venue']);
$res_dur = mysql_real_escape_string$_POST['res_duration']);

$qryjay = mysql_query("SELECT count(*) as countNbr FROM tbl_reservation WHERE res_date='".$res_date."' AND res_dur = '".$res_dur."' AND res_venue = '".$res_venue."'");        
$result = mysql_fetch_assoc($qryjay);
if ($result['countNbr'] > 0)){
    echo "<script language=javascript>alert('".$res_venue." is not available on ".$res_dur." on ".$res_date."!')</script>";
}
?>
于 2013-10-11T09:10:48.453 回答