0

我在 PHP 中有代码:

<?php
// include 'connectss.php';
include 'koneksi.php';

$query= "CALL ws_booking('KLN','MDN','20131012','U15a',2,1,'A','jonie','ivhas,gavas','19900302,19901002','0815123456,08349857345','U77783,K77234','ronas','20100606','5EB9FE68-8915-11E0-BEA0-C9892766ECF2');";
//echo($query); 
$hasil = mysqli_query($koneksii,$query) or die(mysqli_error($koneksii));

while($row = mysqli_fetch_row($hasil))
{
    $trans_hold_id = $row[0];
}   

$kueri = " SELECT 0 as err_code,a.originations_label as org,
    a.destinations_label as des,
    date_format(a.depart_date,'%Y%m%d') as dep_date,
    b.vehicle_no as train_no,
    b.booking_no as book_code,
    get_pax_num_adult(a.booking_no) pax_num,
    get_pax_num_child(a.booking_no) pax_num_ch,
    sf_get_pax_nm(b.pax_id) pax_name,
    b.coach_code,
    b.coach_seq,
    b.seat_str_row,
    b.seat_str_col,
    (select sum(f.TOTAL) 
                    from   fares f, transactions tr 
                    where  tr.FARES_ID = f.FARES_ID 
                    and    tr.TRANS_HOLD_ID = a.TRANS_HOLD_ID) AS normal_sales,
    0 extra_fee,
    a.balance book_balance FROM   transactions_hold a, transactions b  WHERE      b.trans_hold_id = a.trans_hold_id
                    AND a.TRANS_HOLD_ID = '$trans_hold_id'
";
echo($kueri);
$hquery = mysql_query($kueri) or die(mysql_error());

$num_rows = mysql_num_rows($hquery);
echo($num_rows); ?>

ws_booking插入到 MySQL 数据库中,并返回$trans_hold_id以在第二个查询中使用。有$trans_hold_id一个值,但是当我运行第二个查询时,为什么$num_rows返回 0?

请注意,数据存在于数据库中。

4

1 回答 1

0

如果返回 0,并且有数据,则表示查询不正确,尝试直接通过 phpmyadmin 或 mysql 控制台运行

我可以在这里看到您的查询存在一个问题

SELECT 0 as err_code,a.originations_label as org

您可以在此处使用 0 作为列名,而不是将此名称放在i.e in following form0内

于 2013-09-21T17:36:07.677 回答