doupai6875 2010-03-24 23:05
浏览 85
已采纳

PHP错误 - >警告:mysqli_stmt :: execute():无法获取mysqli_stmt | 警告:mysqli_stmt :: close()

I keep getting this error while trying to modify some tables. Here's my code:

/**  <- line 320
 *
 * @param array $guests_array
 * @param array $tickets_array
 * @param integer $seat_count
 * @param integer $order_count
 * @param integer $guest_count
 */
private function book_guests($guests_array, $tickets_array, &$seat_count, 
        &$order_count, &$guest_count){
/* @var $guests_array ArrayObject */
    $sucess = false;
    if(sizeof($guests_array) >= 1){
        //$this->mysqli->autocommit(FALSE);
        //insert the guests into guest, person, order, seat
        $menu_stmt = $this->mysqli->prepare("SELECT id FROM menu WHERE
                    name=?");
        $menu_stmt->bind_param('s',$menu);
        //$menu_stmt->bind_result($menu_id);

        $table_stmt = $this->mysqli->prepare("SELECT id FROM tables WHERE
                    name=?");
        $table_stmt->bind_param('s',$table);
        //$table_stmt->bind_result($table_id);

        $seat_stmt = $this->mysqli->prepare("SELECT id FROM seat WHERE
                    name=? AND table_id=?");
        $seat_stmt->bind_param('ss',$seat, $table_id);
        //$seat_stmt->bind_result($seat_id);
        for($i=0;$i<sizeof($guests_array);$i++){

            $menu = $guests_array[$i]['menu'];
            $table = $guests_array[$i]['table'];
            $seat = $guests_array[$i]['seat'];

            //get menu id
            if($menu_stmt->execute()){
                $menu_stmt->bind_result($menu_id);
                while($menu_stmt->fetch())
                        ;
            }
            $menu_stmt->close();

            //get table id
            if($table_stmt->execute()){
                $table_stmt->bind_result($table_id);
                while($table_stmt->fetch())
                        ;
            }
            $table_stmt->close();

            //get seat id
            if($seat_stmt->execute()){
                $seat_stmt->bind_result($seat_id);
                while($seat_stmt->fetch())
                        ;
            }
            $seat_stmt->close();

            $dob = $this->create_date($guests_array[$i]['dob_day'],
                    $guests_array[$i]['dob_month'],
                    $guests_array[$i]['dob_year']);
            $id = $this->add_person($guests_array[$i]['first_name'],
                    $guests_array[$i]['surname'], $dob,
                    $guests_array[$i]['sex']);

            if(is_string($id)){
                $seat = $this->add_seat($table_id, $seat_id, $id);
                /* @var $tickets_array ArrayObject */
                $guest = $this->add_guest($id,$tickets_array[$i+1],$menu_id,
                        $this->volunteer_id);
                /* @var $order integer */
                $order = $this->add_order($this->volunteer_id, $table_id,
                        $seat_id, $id);

                if($guest == 1 && $seat == 1 && $order == 1){
                    $seat_count += $seat;
                    $guest_count += $guest;
                    $order_count += $order;

                    $success = true;
                }
            }
        }
    }
    return $success;
} <- line 406

Here are the warnings:

The person PRSN10500000LZPH has been added to the guest tablePRSN10500000LZPH added to table (1), seat (1)The order for person(PRSN10500000LZPH) is registered with volunteer (PRSN10500000LZPH) at table (1) and seat (1)PRSN10600000LZPH added to table (1), seat (13)The person PRSN10600000LZPH has been added to the guest tableThe order for person(PRSN10600000LZPH) is registered with volunteer (PRSN10500000LZPH) at table (1) and seat (13) Warning: mysqli_stmt::execute(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 358 Warning: mysqli_stmt::close(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 363 Warning: mysqli_stmt::execute(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 366 Warning: mysqli_stmt::close(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 371 Warning: mysqli_stmt::execute(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 374 Warning: mysqli_stmt::close(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 379 PRSN10700000LZPH added to table (1), seat (13)The person PRSN10700000LZPH has been added to the guest tableThe order for person(PRSN10700000LZPH) is registered with volunteer (PRSN10500000LZPH) at table (1) and seat (13) Warning: mysqli_stmt::execute(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 358 Warning: mysqli_stmt::close(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 363 Warning: mysqli_stmt::execute(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 366 Warning: mysqli_stmt::close(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 371 Warning: mysqli_stmt::execute(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 374 Warning: mysqli_stmt::close(): Couldn't fetch mysqli_stmt in /Users/olatunjigbadamosi/Sites/ST_Ambulance/FormDB.php on line 379 PRSN10800000LZPH added to table (1), seat (13)The person PRSN10800000LZPH has been added to the guest tableThe order for person(PRSN10800000LZPH) is registered with volunteer (PRSN10500000LZPH) at table (1) and seat (13)
  • 写回答

1条回答 默认 最新

  • douguiyan9164 2010-03-25 00:28
    关注

    I don't think it will work this way. When you close the statement (e.g. $menu_stmt->close();) you also deallocate the statement handle. So the second time through the loop you don't have the prepared statements available to work with anymore.

    Try closing the statements after the loop has finished executing.

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

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)