Blank page when creating table

1

I have a query that the following appears in the logs of the web server and does not show me anything in the Browser:

  

PHP Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given

The code I have is the following:

 <?php
 include("conn.php");


$result = mysql_query("SELECT name, COUNT(IF(stat='open',1, NULL)) 'open',
       COUNT(IF(stat='close',1, NULL)) 'close',
       COUNT(IF(stat='all',1, NULL)) 'all',
       COUNT(IF(stat='reopen',1, NULL)) 'reopen',
       COUNT(IF(stat='finish',1, NULL)) 'finish'
FROM dashboard group by name order by name = 'Party' desc");


 while($test = mysql_fetch_array($result))
 {
 $id = $test['id'];
 echo"<td>".$test['name']."</td>";
 echo"<td>".$test['open']."</td>";
 echo"<td>".$test['close']."</td>";
 echo"<td>".$test['all']."</td>";
 echo"<td>".$test['reopen']."</td>";
 echo"<td>".$test['finish']."</td>";
 echo "</tr>";
 }
 mysql_close($conn);
 ?>

whereas if I put the following query if I see data:

 $result = mysql_query("SELECT * FROM dashboard");

What is failing me?

The query works if I run it on the console:

+----------+------+-------+-----+--------+--------+
| name     | open | close | all | reopen | finish |
+----------+------+-------+-----+--------+--------+
| Party    |   21 |     0 |   0 |      0 |      0 |
| Party1   |    0 |     0 |   0 |      0 |      0 |
| Party2   |    0 |     0 |   0 |      0 |      0 |
| Party3   |    2 |     0 |   0 |      0 |      0 |
+----------+------+-------+-----+--------+--------+

I update with data from the table:

+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| name        | varchar(50)  | YES  |     | NULL    |                |
| description | varchar(200) | YES  |     | NULL    |                |
| stat        | varchar(20)  | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+

At the moment that the error Unknown column 'stat' in 'field list' appears, it does exist:

MariaDB [rt2]> select stat from dashboard where stat = 'finish' limit 1;
+---------+
| stat    |
+---------+
| finish  |
+---------+
1 row in set (0.01 sec)
    
asked by Guif If 13.11.2018 в 01:06
source

0 answers