I'm a bit baffled about this. Explanation of the issue is:
- Query sql returns 6 rows of data (of 14 fields each) when run in
phpMyAdmin - On the php page mysqli_num_rows returns: 6
- print_r($sql_res) returns: mysqli_result Object ( [current_field] => 0 [field_count] => 14 [lengths] => [num_rows] => 6 [type] => 0 )
- var_dump($sql_res) returns: object(mysqli_result)#1 (5) { ["current_field"]=> int(0) ["field_count"]=> int(14) ["lengths"]=>
NULL ["num_rows"]=> int(6) ["type"]=> int(0)
There is data in the db, but is not being parsed into the table structure since no data containing field values are returned. Any help or pointers would highly be appreciated.
DB connection is OK, my other pages are working, I'm using session variables in query ($selected and $selfair), my php code that gives the headache is:
$sql = "SELECT har_id, har_fair_id, har_kat_id, har_tarih, har_co_id, har_desc, har_docno, har_kur, har_debit, har_credit, har_used, har_invoiced, har_cancelled, har_schid FROM hareketler WHERE har_co_id =". $selected." AND har_fair_id =". $selfair;
echo $sql."
";
//sql returns correct statement
$sql_res = mysqli_query($con, $sql);
print_r($sql_res)."
";
echo "
".mysqli_num_rows($sql_res);
// row count is 6 but no other data is fetched from db!
echo "
".var_dump($sql_res);
while($row = mysqli_fetch_array($sql_res,MYSQLI_ASSOC));{
// detail rows are NOT fetched!
if($row<>''){
echo '';
echo '';
echo ''.$row['har_id'].' ';
echo ''.$row['har_fair_id'].' ';
echo ''.$row['har_kat_id'].' ';
echo ''.$row['har_tarih'].' ';
echo ''.$row['har_co_id'].' ';
echo ''.$row['har_desc'].' ';
echo ''.$row['har_docno'].' ';
echo ''.$row['har_kur'].' ';
echo ''.$row['har_debit'].' ';
echo ''.$row['har_credit'].' ';
echo ''.$row['har_used'].' ';
echo ''.$row['har_invoiced'].' ';
echo ''.$row['har_cancelled'].' ';
echo ''.$row['har_schid'].' ';
echo ' ';
echo '';
}
else {
echo "
No data returned!";
// sql is correct but no detail data is fetched!
}
}
?>
Thanks in advance.
Alp
No comments:
Post a Comment