简体   繁体   中英

php query not returning results

I am attempting to execute a php query with no results. I have been trying to get it to work for hours and figure another set of eyes would be helpful. Here is my script:

if(!empty($cLvl))
{
    $result = $conn->query("SELECT lvl" . $cLvl . " 
    FROM buyers WHERE buyer_id = $buyer");

    $comRate = $result->fetch_assoc();
}
print_r($comRate); die;

$buyer is found by:

$result = $conn->query("select source_id from inventory where sku = {$data[$n]['sku']}");
if($result) {$buyer = $result->fetch_assoc();}

and $cLvl is found by:

if($data[$n]['cost'] == 0 || $bookType3['book_type_3'] == "DMG")
{
    $cLvl = null;
}
elseif($bookType['book_code'] == "IE" || $bookType['book_code'] == "AIE")
{
    $cLvl = 3;
}
elseif($cId['condition_id'] == 1 || $cId['condition_id'] == 2 || $cId['condition_id'] == 3 || $cId['condition_id'] == 4 || $follett['class_code'] == "D" || strpos($follett['notes'],"(T)") == true)
{
    $cLvl = 2;
}
elseif($cId['condition_id'] == 5)
{
    $cLvl = 1;
}

in my testing $buyer = 263 and $cLvl = 3 . However when I try to find $comRate , it returns nothing. If I hard code in the information I get a result, but this is going to run about 250 records and I can't be hardcoding each one.

Where am I going wrong with this??

这段代码有很多地方是错误的,但是您所要求的可能是$buyer是一个assoc数组,而您想使用{$buyer['source_id']}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM