C
C
Chvalov2015-11-06 12:33:37
PHP
Chvalov, 2015-11-06 12:33:37

Doesn't output data from InterBase database, what's wrong?

Request

SELECT  UNITSTAT, DTSTAT, UNITID,
0 PhNom, 0 PhMax, 0 PhA, 0 PhB, 0 PhC
from STATHIST
WHERE UNITID = 216
AND DtStat between '01.10.2015 11:19' and '06.11.2015 11:19'
ORDER BY DTSTAT DESC
ROWS 20
executed in IBExpert returns me the following: e91f659c0d91462ebcd11c273c891421.png
But the same query only in PHP returns empty columns to me:
4e00abd7033d45f99830a5d611111706.png
Here is the code:
<?php
            include ("bd_config.php");   // подключение блока где реализуется подключение к БД
            $strSQL = "SELECT  UNITSTAT, DTSTAT, UNITID, 0 PhNom, 0 PhMax, 0 PhA, 0 PhB, 0 PhC from STATHIST
            WHERE UNITID = 215
            AND DtStat between '".$_POST['date_start']."' and '".$_POST['date_stop']."'
            ORDER BY DTSTAT DESC
            ROWS 20"; // запрос
            
            $rs = ibase_query($strSQL, $db);                          
            $table = "<table border=1 width = '600px' align=center>";
                $k=1;
            while($row = ibase_fetch_row($rs)) {                   //цикл
            if($k%2==0) $color="#FFFFFF";else $color="#C0C0C0"; 
                $k++;
                $table .= "<tr BGCOLOR='$color'>";
                $table .= "<td >".$row['UNITSTAT']."</td>";
                $table .= "<td >".$row['DTSTAT']."</td>";
                $table .= "<td >".$row['UNITID']."</td>";
                $table .= "<td >".$row['PHNOM']."</td>";
                $table .= "<td >".$row['PHMAX']."</td>";
                $table .= "<td >".$row['PHA']."</td>";
                $table .= "<td >".$row['PHB']."</td>";
                $table .= "<td >".$row['PHC']."</td>";
                $table .= "</tr>";
                  }
            
            $table .= "</table>";
                    echo $table;           // выводится
            ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2015-11-06
@Chvalov

I see that the number of rows is the same as IBExpert . So just put in a template
You will see what the $row variable consists of, and it will be visible there.
ibase_fetch_row - returns an array where indexes are numbers, ibase_fetch_assoc - returns an array where indexes correspond to field names.
Or change
$table .= "".$row['INITSTAT']."";
on
$table .= "".$row[0]."";
and further by analogy
Either There is another option to change the function to ibase_fetch_assoc, it will return an array with field names.
In addition, to prevent errors from ibase_fetch_row and ibase_fetch_assoc, it is worth checking the response to the database call. If not FALSE, then the request was successful.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question