简体   繁体   English

致命错误:带有消息“ SQLSTATE [HY000]:常规错误”的未捕获异常“ PDOException” .. C:\\ xampp \\ .. PDOStatement-> fetch()..第83行

[英]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.

相关问题 致命错误:未捕获异常&#39;PDOException&#39;,消息&#39;SQLSTATE [HY000]:常规错误&#39;中 - Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' in SQLSTATE [HY000]:PDOStatement-&gt; fetchAll(2)上的一般错误 - SQLSTATE[HY000]: General error on PDOStatement->fetchAll(2) 致命错误:未捕获的 PDOException:SQLSTATE[HY000]:一般错误 - Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error 致命错误:未被捕获的PDOException:SQLSTATE [HY000]:常规错误:提取模式要求在 - Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: fetch mode requires the classname argument in PHP:致命错误:未捕获的 PDOException:SQLSTATE[HY000] - PHP: Fatal error: Uncaught PDOException: SQLSTATE[HY000] 致命错误:未捕获的 PDOException:SQLSTATE [HY093]:无效参数编号:参数未在 (xxx) PDOStatement->execute() 中定义 - Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in (xxx) PDOStatement->execute() 致命错误:未捕获的 PDOException:SQLSTATE [HY000]:一般错误:2014 存在未决结果集时无法执行查询 - Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets 未捕获的异常&#39;PDOException,消息为&#39;SQLSTATE [HY000] [2013] - Uncaught exception 'PDOException with message 'SQLSTATE[HY000] [2013] /media/Data/Documenten/PHP/µBot/index.php:100中未捕获的异常“ PDOException”,消息为“ SQLSTATE [HY000]:一般错误:20个数据类型不匹配” - Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 20 datatype mismatch' in /media/Data/Documenten/PHP/µBot/index.php:100 邮递员:未捕获的PDOException:SQLSTATE [HY000]:常规错误:1366不正确的整数值:&#39;&#39; - Postman: Uncaught PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ''
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM