Php mysql_num_rows返回0,但数据存在于数据库中
我有PHP代码:Php mysql_num_rows返回0,但数据存在于数据库中,php,mysql,mysql-num-rows,Php,Mysql,Mysql Num Rows,我有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-
<?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); ?>
如果返回0,并且数据存在,则表示查询不正确,请尝试直接通过phpmyadmin或mysql控制台运行它
我可以看出你的问题在这里
SELECT 0 as err_code,a.originations_label as org
您可以在此处使用0作为列名,而不是将此名称放在中,即以以下形式
0`存储过程可能会返回缓冲结果集。请通过电子邮件检查它们。使用mysqli\u fetch\u row()
fromCALL
query来获取resultset可能不够。@他没有使用mysqli,他使用的是mysql。正如@Barmar提到的,您的第二次查询执行是使用另一个扩展的函数。请注意,mysql\u查询
不是mysqli\u查询
。它们是不同的。啊,我只看底部,不看顶部!但是我对第一个查询“CALL ws_booking('KLN',…)没有问题,我的问题是第二个查询在mysql_num_行中返回0…他没有尝试使用0
作为列名,它是一个文本整数。