PDO查询错误[关闭]

Why this PHP lines do not work ?

I'm using PDO.

Thanks.

-

if($arr['target_action']=="new") {
    $query = $pdo->prepare('INSERT INTO ___Bookings VALUES ("", ":hotel_id", ":BOO_RoomId", ":BOO_ClientId", ":BOO_DateCI", ":BOO_DateCO", ":BOO_Rate", "", "", "'.date('Y-m-d H:i:s').'", ":BOO_Status")');
    $query->execute(array(':BOO_RoomId' => $arr['rid'], ':BOO_ClientId' => $arr['BOO_ClientId'], ':BOO_DateCI' => $arr['cid'], ':BOO_DateCO' => $arr['cod'], ':BOO_Rate' => $arr['BOO_Rate'], ':BOO_Status' => $arr['BOO_Status'], ':hotel_id' => $_SESSION['CurrentLogged_HOT_HotelId'])); 
}

You need to remove the quotes around your placeholders.

if($arr['target_action'] == "new") {
    $query = $pdo->prepare("INSERT INTO ___Bookings VALUES ('', :hotel_id, :BOO_RoomId, :BOO_ClientId, :BOO_DateCI, :BOO_DateCO, :BOO_Rate, '', '', :Date, :BOO_Status)");
    $query->execute(array(':BOO_RoomId' => $arr['rid'], ':BOO_ClientId' => $arr['BOO_ClientId'], ':BOO_DateCI' => $arr['cid'], ':BOO_DateCO' => $arr['cod'], ':BOO_Rate' => $arr['BOO_Rate'], ':BOO_Status' => $arr['BOO_Status'], ':hotel_id' => $_SESSION['CurrentLogged_HOT_HotelId'], ':Date' => date('Y-m-d H:i:s'))); 
}

Also, why did you use string interpolation for the date?! Use a placeholder for that one, too!