douxunchen3498 2011-10-05 19:48
浏览 59

PHP db2_fetch_assoc和db2_fetch_both

I'm successfully connecting to the database, and successfully pulling data and displaying it using db2_fetch_array and db2_fetch_both. The code below works just fine

$file="m03slsd0";
$file=db2_escape_string($file);
$query="SELECT slgrpn,slfrkn,slftyp,slfsze,slpqty,slpwht,slentp,slkplt FROM HUTALIB.$file";
$quepre=db2_prepare($conn,$query);
$quexe=db2_execute($quepre);

while($row=db2_fetch_both($quepre))
{
$det=$row[0];
if($det!='')
{
printf($det."</br>");
}
}

The problem comes up when i'm changing the index to column name in db2_fetch_assoc() or db2_fetch_array() - the code below prints nothing.

while($row=db2_fetch_both($quepre))
{
$det=$row['slgrpn'];
if($det!='')
{
printf($det."</br>");
}
}

Any suggestions?

Thanks in advance

  • 写回答

2条回答 默认 最新

  • doulai8128 2011-10-05 20:15
    关注

    Array ( [SLGRPN] => 12626 ...

    Array keys are case sensitive you you will need to use

    $det=$row['SLGRPN'];
    

    not sure why the field names get turned into uppercase - it might be a characteristic of db2.

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示