douqinlu4217 2015-05-17 20:15
浏览 20

循环执行时PHP存储过程错误

I have the PHP script :

<?php       
    $count=1;
    $result = $db_connection->prepare("SELECT tid, title FROM message");
    $result->execute();

    while($row = $result->fetch())
    {
        $co_count = 0;
        $cosql = $db_connection->prepare("CALL sp_getresp(?);");
        $cosql->execute(array($row['tid']));

        while($row3 = $cosql->fetch())
        {
            // GET USERS INFO
            $couser = $db_connection->prepare("CALL sp_getuserinfo(?);");
            $couser->execute(array($row3['couid']));
            $row4 = $couser->fetch();

            var_dump($row4);
            echo '<BR>'.$row['tid'].$row4['email'].'<BR>';
            $count++;

        }
    }
?>

In the above code, I try to run the stored procedure. It is working fine except, in the first loop, it doesnt give any data even the data is present. I tried many tests, but $row4['email'] always shows empty in the first loop time, after first loop, it runs fine. I also check directly calling CALL sp_getuserinfo(?); in the mysql where it works fine but not here. I dont understand what is the problem here ?

  • 写回答

0条回答 默认 最新

      编辑
      预览

      报告相同问题?

      手机看
      程序员都在用的中文IT技术交流社区

      程序员都在用的中文IT技术交流社区

      专业的中文 IT 技术社区,与千万技术人共成长

      专业的中文 IT 技术社区,与千万技术人共成长

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      客服 返回
      顶部