我正在尝试运行SQL查询但是我收到以下错误: mysqli_fetch_array()期望参数1为mysqli_result,boolean given
我的代码:
$pricerange = $_GET['pricerange'];
$ary = explode("-",$pricerange);
$price_min = filter_var($ary[0], FILTER_SANITIZE_NUMBER_INT);
$price_max = filter_var($ary[1], FILTER_SANITIZE_NUMBER_INT);
$card_data = mysqli_query($con, "SELECT * FROM builds WHERE approved = 'yes' WHERE build_price >= '$price_min' AND build_price <= '$price_max'");
$card_data_result = mysqli_fetch_array($card_data);
$pricerange = $_GET['pricerange'];
我已经做了一些关于错误及其错误的研究,因为查询返回false或true(它似乎没有)任何想法如何修复它?
答案 0 :(得分:2)
您在选择查询中使用了两个where
子句。
试试这个,
SELECT * FROM builds WHERE approved = 'yes' and build_price >= '$price_min' AND build_price <= '$price_max'
OR
SELECT * FROM builds WHERE approved = 'yes' and build_price BETWEEN '$price_min' AND '$price_max'
而不是
SELECT * FROM builds WHERE approved = 'yes' WHERE build_price >= '$price_min' AND build_price <= '$price_max'