แค่กลับขึ้น error ดังนี้ครับ Fatal error: Uncaught Error: Call to a member function query() on null in /storage/ssd5/912/11562912/public_html/0000/0000.php:21 Stack trace: #0 {main} thrown in /storage/ssd5/912/11562912/public_html/0000/0000.php on line 21
<?php
$conn= mysqli_connect("localhost","0000","0000","0000") or die("Error: " . mysqli_error($con));
mysqli_query($conn, "SET NAMES 'utf8' ");
$mysqli = null;
if(isset($_GET["DATE"]))
{
$mysqli = $_GET["DATE"];
}
$i=1;
$query="SELECT a.*,
(SELECT COUNT(b.DATE) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as num,
(SELECT SUM(b.A_K) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_A,
(SELECT SUM(b.B_K) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_B,
(SELECT SUM(b.C_K) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_C,
(SELECT MAX(b.A_W) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_A,
(SELECT MAX(b.B_W) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_B,
(SELECT MAX(b.C_W) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_C
FROM meter a ORDER BY a.DATE ASC
";
$result = $mysqli->query($query); // ทำการ query คำสั่ง sql
$total=$result->num_rows; // นับจำนวนถวที่แสดง ทั้งหมด
$aggr_arr=array();
while($row=$result->fetch_array()){ // วนลูปแสดงข้อมูล
$dateKey=date("dmY",strtotime($row['DATE']));
$row_span=0;
if(!isset($aggr_arr[$dateKey])){
$aggr_arr[$dateKey]=array();
$row_span=1;
}
?>
<table width="1300" border="1" cellpadding="10" align="center">
<tr> <tr><td rowspan="2" align="center">Date Day</td>
<td colspan="3" align="center">A</td>
<td colspan="3" align="center">Phase B</td>
<td colspan="3" align="center">Phase C</td>
</tr>
<td align="center">Average</td>
<td align="center">Maximum</td>
<td align="center">Load</td>
<td align="center">Average</td>
<td align="center">Maximum</td>
<td align="center">Load</td>
<td align="center">Average</td>
<td align="center">Maximum</td>
<td align="center">Load</td>
<tr>
<td rowspan="3" align="center" width="15%"><h1><font size="8"><?=$row['DATE']?></td>
<td><?=$row['avg_A']?></td>
<td><?=$row['max_A']?></td>
<td><h4></td>
<td><h4><?=$row['avg_B']?></td>
<td><?=$row['max_B']?></td>
<td><h4></td>
<td><?=$row['avg_C']?></td>
<td><?=$row['max_C']?></td>
<td><h4></td>
</tr>
<?php $i++; } ?>
</table>
Notice: Trying to get property 'num_rows' of non-object in /storage/ssd5/912/11562912/public_html/0000/0000.php on line 22
Fatal error: Uncaught Error: Call to a member function fetch_array() on boolean in /storage/ssd5/912/11562912/public_html/0000/0000.php:24 Stack trace: #0 {main} thrown in /storage/ssd5/912/11562912/public_html/0000/0000.php on line 24
Notice: Trying to get property 'num_rows' of non-object in /storage/ssd5/912/11562912/public_html/0000/0000.php on line 19
Fatal error: Uncaught Error: Call to a member function fetch_array() on boolean in /storage/ssd5/912/11562912/public_html/test1/0000/0000.php:21 Stack trace: #0 {main} thrown in /storage/ssd5/912/11562912/public_html/test1/0000/0000.php on line 21
Code (PHP)
<?php
$conn= mysqli_connect("localhost","0000","0000","0000") or die("Error: " . mysqli_error($con));
mysqli_query($conn, "SET NAMES 'utf8' ");
$i=1;
$query="SELECT a.*,
(SELECT COUNT(b.DATE) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as num,
(SELECT SUM(b.A_K) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_A,
(SELECT SUM(b.B_K) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_B,
(SELECT SUM(b.C_K) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_C,
(SELECT MAX(b.A_W) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_A,
(SELECT MAX(b.B_W) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_B,
(SELECT MAX(b.C_W) FROM meter b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_C
FROM meter a ORDER BY a.DATE ASC
";
$result = $conn->query($q); // ทำการ query คำสั่ง sql
if (!$conn->error) {
printf("Error message: %s\n", $conn->error);
}
$total=$result->num_rows; // นับจำนวนถวที่แสดง ทั้งหมด
$aggr_arr=array();
while($row=$result->fetch_array()){ // วนลูปแสดงข้อมูล
$dateKey=date("dmY",strtotime($row['DATE']));
$row_span=0;
if(!isset($aggr_arr[$dateKey])){
$aggr_arr[$dateKey]=array();
$row_span=1;
}
?>
<table width="1300" border="1" cellpadding="10" align="center">
<tr> <tr><td rowspan="2" align="center">Date Day</td>
<td colspan="3" align="center">A</td>
<td colspan="3" align="center">Phase B</td>
<td colspan="3" align="center">Phase C</td>
</tr>
<td align="center">Average</td>
<td align="center">Maximum</td>
<td align="center">Load</td>
<td align="center">Average</td>
<td align="center">Maximum</td>
<td align="center">Load</td>
<td align="center">Average</td>
<td align="center">Maximum</td>
<td align="center">Load</td>
<tr>
<td rowspan="3" align="center" width="15%"><h1><font size="8"><?=$row['DATE']?></td>
<td><?=$row['avg_A']?></td>
<td><?=$row['max_A']?></td>
<td><h4></td>
<td><h4><?=$row['avg_B']?></td>
<td><?=$row['max_B']?></td>
<td><h4></td>
<td><?=$row['avg_C']?></td>
<td><?=$row['max_C']?></td>
<td><h4></td>
</tr>
<?php $i++; } ?>
</table>
Notice: Undefined index: DATE in /storage/ssd5/912/11562912/public_html/test1/0000.php on line 15
Error message:
Code (PHP)
<?php
$conn= mysqli_connect("localhost","0000","0000","0000") or die("Error: " . mysqli_error($con));
mysqli_query($conn, "SET NAMES 'utf8' ");
$i=1;
$q="SELECT a.*,
(SELECT COUNT(b.DATE) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as num,
(SELECT SUM(b.M_A_KWH) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_A,
(SELECT SUM(b.M_B_KWH) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_B,
(SELECT SUM(b.M_C_KWH) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as avg_C,
(SELECT MAX(b.M_A_WATT) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_A,
(SELECT MAX(b.M_B_WATT) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_B,
(SELECT MAX(b.M_C_WATT) FROM test1 b WHERE b.DATE=a.DATE GROUP BY b.DATE) as max_C
FROM test1 a ORDER BY a.DATE ASC
";
$DATE=$_GET['DATE'];
$q="select * from test1 where DATE='$DATE'";
$result = $conn->query($q); // ทำการ query คำสั่ง sql
if (!$conn->error) {
printf("Error message: %s\n", $conn->error);
}
$total=$result->num_rows; // นับจำนวนถวที่แสดง ทั้งหมด
$aggr_arr=array();
while($row=$result->fetch_array()){ // วนลูปแสดงข้อมูล
$dateKey=date("dmY",strtotime($row['DATE']));
$row_span=0;
if(!isset($aggr_arr[$dateKey])){
$aggr_arr[$dateKey]=array();
$row_span=1;
}
?>
<table width="800" border="1" cellpadding="10" align="center">
<tr> <tr><td rowspan="2" align="center">Date Day</td>
<td colspan="3" align="center">Phase A</td>
<td colspan="3" align="center">Phase B</td>
<td colspan="3" align="center">Phase C</td>
</tr>
<td align="center">Average Energy per Day</td>
<td align="center">Maximun Load per Day</td>
<td align="center">Load Factor per Day</td>
<td align="center">Average Energy per Day</td>
<td align="center">Maximun Load per Day</td>
<td align="center">Load Factor per Day</td>
<td align="center">Average Energy per Day</td>
<td align="center">Maximun Load per Day</td>
<td align="center">Load Factor per Day</td>
<tr>
<td align="center" width="15%"><h1><font size="8"><?=$row['DATE']?></td>
<td align="center" bgcolor="FFE6E6"><h4><?=$row['avg_A']?></td>
<td align="center" bgcolor="FFE6E6"><h4><?=$row['max_A']?></td>
<td align="center" bgcolor="FFE6E6"><h4></td>
<td align="center" bgcolor="C8FFFF"><h4><?=$row['avg_B']?></td>
<td align="center" bgcolor="C8FFFF"><h4><?=$row['max_B']?></td>
<td align="center" bgcolor="C8FFFF"><h4></td>
<td align="center" bgcolor="FAFAD2"><h4><?=$row['avg_C']?></td>
<td align="center" bgcolor="FAFAD2"><h4><?=$row['max_C']?></td>
<td align="center" bgcolor="FAFAD2"><h4></td>
</tr>
<?php $i++; }?>
</table>
Warning: A non-numeric value encountered in /var/www/vhosts/beemortar.com/b.beemortar.com/wp-content/plugins/fusion-builder/inc/class-fusion-row-element.php on line 160 แก้ยังไงคะ