[英]Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' .. C:\xampp\..PDOStatement->fetch().. on line 83
I have actually seen similar questions on this "Fatal error: Uncaught exception 'PDOException'". 我实际上已经在此“致命错误:未捕获的异常'PDOException'”上看到了类似的问题。 But I have not been able to use have I have seen to resolve the challenge am having. 但是我没有看到解决解决挑战的方法。
Below the code and the error message 下面的代码和错误消息
<?php
$sql5 = " set @rownum := 0;
set @sum := 0;
select DISTINCT(ROUND(the_avg,4))
FROM (
select water_level,
@rownum := (@rownum + 1) as rownum,
@sum := IF(@rownum mod 7 = 1,0 + water_level,@sum + water_level) as running_sum,
IF(@rownum mod 7 = 0,@sum / 7,NULL) as the_avg
FROM " .$table." WHERE record_month_year = '".$startDateReport."'
order by id ASC
) s ";
$result5 = $db->prepare($sql5);
$result5->execute();
while ($rowReport = $result5->fetch(PDO::FETCH_ASSOC)) {
?>
<tr style="font-size:11px;">
<td><?php echo $rowReport['the_avg'] ; ?></td>
</tr>
<?php
}
?>
The line 83 is : 第83行是:
while ($rowReport = $result5->fetch(PDO::FETCH_ASSOC)) {
error: 错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' in C:\\xampp\\htdocs\\awos\\includes\\loadboreholedatareport.php:83 Stack trace: #0 C:\\xampp\\htdocs\\awos\\includes\\loadboreholedatareport.php(83): PDOStatement->fetch() #1 C:\\xampp\\htdocs\\awos\\borData-report.php(46): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\\xampp\\htdocs\\awos\\includes\\loadboreholedatareport.php on line 83. 致命错误:C:\\ xampp \\ htdocs \\ awos \\ includes \\ loadboreholedatareport.php:83中未捕获的异常'PDOException',消息为'SQLSTATE [HY000]:General error',堆栈跟踪:#0 C:\\ xampp \\ htdocs \\ awos \\ include \\ loadboreholedatareport.php(83):PDOStatement-> fetch()#1 C:\\ xampp \\ htdocs \\ awos \\ borData-report.php(46):include('C:\\ xampp \\ htdocs ...')# 2第83行上的{main}放在C:\\ xampp \\ htdocs \\ awos \\ includes \\ loadboreholedatareport.php中。
You can only do one query at a time with PDO.. Do them separately, like this.. 您只能使用PDO一次执行一个查询。像这样单独进行查询。
$db->query("set @rownum := 0");
$db->query("set @sum := 0");
$sql5 = "select DISTINCT(ROUND(the_avg,4))
FROM (
select water_level,
@rownum := (@rownum + 1) as rownum,
@sum := IF(@rownum mod 7 = 1,0 + water_level,@sum + water_level) as running_sum,
IF(@rownum mod 7 = 0,@sum / 7,NULL) as the_avg
FROM " .$table." WHERE record_month_year = '".$startDateReport."'
order by id ASC
) s ";
And the rest would be the same. 其余的将是相同的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.