stockton Posted December 17, 2010 Share Posted December 17, 2010 I get no results if I run the following program, but if I cut and paste the echoed SQL into Apex SQL Commands I do get the results that I am after. Please tell me what I have done wrong? <?php global $conn; /* * Main body starts here * */ echo "Test for 20101207 <br />"; $conn=oci_connect("s7s", "big", "localhost"); if ( ! $conn ) { $e = oci_error(); // For oci_connect errors pass no handle echo "Unable to OCILogon to database. ".$e["message"]; die(); } else { echo "Connected<br />"; } $Event = "203"; $MemberNum = "2020230335"; // "2020000669"; $StartDate = "2010-04-01 00:00:00"; $EndDate = "2010-10-28 23:59:59"; $TablesArray = array(1, 3); $TablesCount = 2; $Datum = date("Y-m-d H:i:s"); /* 2006-03-17 23:22:32 */ $TableTickets = $SlotsTickets = $TableTurnover = $SlotsTurnover = $BonusTickets = $TicketsAlreadyIssued = 0; $TableTickets = $SlotsTickets = $TableTurnover = $SlotsTurnover = 0; $SQL = "SELECT trans_code,trans_table_name,SUM(TRANS_TURNOVER) TablesTurnover "; $SQL .= "FROM TRANSACT "; $SQL .= "join tables on trans_table_name = tbl_code "; $SQL .= "where TRANS_CODE = '".$MemberNum."' AND "; $SQL .= "TRANS_DATE BETWEEN TO_DATE('".$StartDate."','YYYY/MM/DD HH24:MI:SS') AND "; $SQL .= "TO_DATE('$EndDate','YYYY/MM/DD HH24:MI:SS')"; $i = 0; if ($TablesCount > 0) { $SQL .= " AND ("; } else { $SQL .= ";"; } while ($i < $TablesCount) { $SQL .= "tbl_pit = '"; $SQL .= $TablesArray[$i]; $i++; if ($i < $TablesCount) $SQL .= "' or "; else $SQL .= "') Group by trans_code, trans_table_name;"; } echo "Tables<br />".$SQL."<br />"; $stmt = oci_parse($conn, $SQL); oci_execute($stmt); while ($row = oci_fetch_row($stmt)) echo htmlentities($row)." "; ?> Result from program/script is:- Test for 20101207 Connected Tables SELECT trans_code,trans_table_name,SUM(TRANS_TURNOVER) TablesTurnover FROM TRANSACT join tables on trans_table_name = tbl_code where TRANS_CODE = '2020230335' AND TRANS_DATE BETWEEN TO_DATE('2010-04-01 00:00:00','YYYY/MM/DD HH24:MI:SS') AND TO_DATE('2010-10-28 23:59:59','YYYY/MM/DD HH24:MI:SS') AND (tbl_pit = '1' or tbl_pit = '3') Group by trans_code, trans_table_name; result from Apex is:- 2020230335 PB02 25093333.33 2020230335 AR25 6708333.34 2020230335 AR18 0 2020230335 PB08 21054167.21 2020230335 AR20 0 2020230335 AR16 0 2020230335 AR19 0 2020230335 AR15 1590458.33 2020230335 BJ20 0 2020230335 PB07 2672066.67 Link to comment https://forums.phpfreaks.com/topic/221969-windows-php-5214-and-oracle-10g/ Share on other sites More sharing options...
trq Posted December 17, 2010 Share Posted December 17, 2010 Define 'No Result'. Link to comment https://forums.phpfreaks.com/topic/221969-windows-php-5214-and-oracle-10g/#findComment-1148587 Share on other sites More sharing options...
stockton Posted December 17, 2010 Author Share Posted December 17, 2010 From my original message I would have thought that it was obvious that I am getting all the echos displayed but no data from the database. I apologise if I was not clear enough. Link to comment https://forums.phpfreaks.com/topic/221969-windows-php-5214-and-oracle-10g/#findComment-1148608 Share on other sites More sharing options...
trq Posted December 17, 2010 Share Posted December 17, 2010 oci_fetch_row returns an array. You cannot echo an array. Link to comment https://forums.phpfreaks.com/topic/221969-windows-php-5214-and-oracle-10g/#findComment-1148612 Share on other sites More sharing options...
stockton Posted December 17, 2010 Author Share Posted December 17, 2010 even if I:- while ($row = oci_fetch_all ($stmt)) { $GameType = $row[0]; $Turnover = $row[1]; } I get nothing returned from the database.][/code] Link to comment https://forums.phpfreaks.com/topic/221969-windows-php-5214-and-oracle-10g/#findComment-1148668 Share on other sites More sharing options...
Adam Posted February 2, 2011 Share Posted February 2, 2011 Try: print_r($row); Within the loop. Link to comment https://forums.phpfreaks.com/topic/221969-windows-php-5214-and-oracle-10g/#findComment-1168996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.