douyoufan7881 2014-01-14 12:17
浏览 61

PHP / MySql未定义索引:id从MySql表中检索数据时

I'm trying to retrieve some data from the MySql table. But when I run the query, It showing Notice : Undefined index: id. But when I run the same query in SQLyog it is showing the correct result. Without any error.

Query :

SELECT id,temp_name,added,updated FROM `projtemp` WHERE `user_id`='0000000001' 

Out from SQLyog :

enter image description here

Error From Firebug Console :

<b>Notice</b>:  Undefined index: id in <b>C:\xampp\htdocs\xxx\yyy\zzz\aaa.php</b> on line <b>61</b><br />

Php Code which I executed :

try {
        $paginate = new pagination($page, "SELECT id,temp_name,added,updated FROM `projtemp` WHERE `user_id`='$uid'", $options);
    } catch (paginationException $e) {
        echo $e;
        exit();
    }

Update :

       if ($paginate->success == true) {
        while ($row = $result->fetch_assoc()) {
            $temp=array();
            $temp['id']=$row['id'];   // In this line I'm Getting Error Line-61
           $temp['tname'] = $row['temp_name'];
            $temp['added'] = $row['added'];
            if ($row['updated'] == '') {
                $temp['updated'] = 'Never';
            } else {
                $temp['updated'] = $row['updated'];
            }
            $data['data']=$temp;
        }

Please any one help me to solve this issue....

  • 写回答

4条回答 默认 最新

  • drxv39706 2014-01-14 12:19
    关注

    Try this, you don't need enclose with '' for integer field

    $paginate = new pagination($page, "SELECT id,temp_name,added,updated FROM `projtemp` WHERE `user_id`=$uid", $options);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?