doutao6653 2012-07-17 19:18
浏览 17
已采纳

php查询没有返回结果

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??

  • 写回答

1条回答 默认 最新

  • dongshi8359 2012-07-17 19:22
    关注

    A whole lot is wrong with this code, but what you're asking for is probably that your $buyer is an assoc array, you want to use {$buyer['source_id']} instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?