警告:odbc_fetch_row():37不是有效的ODBC结果资源

时间:2010-12-17 03:48:47

标签: php

我的代码出错了,当我测试它时输出会写入但是在我的浏览器中显示警告说“警告:odbc_fetch_row():37不是C:\ xampp \ htdocs \ webinterface中的有效ODBC结果资源” \ requests.php在第729行“

我不知道它是什么意思,sql语句结果在dbexplorer中正常。 顺便说一句,数据库可能是矛盾的,并使用odbc将我的php连接到paradox。

有人可以帮助我吗?非常感谢你

我的代码如下:

    $connectionstring = odbc_connect(DB_DNS,DB_USER,DB_PASS);
        $auditRequestNo     = "";
        $ar_requestno   = "";
        $svemp1 = "";
        $svemp2 = "";               
        foreach($uArr as $arNo){                
            $ar_requestno .= (!empty($ar_requestno))? ",".$arNo : $arNo;
            $auditRequestNo   .= (!empty($auditRequestNo))? ",".sprintf("%08d", $arNo) : sprintf("%08d", $arNo);
        }

        $query = "SELECT SV_EmployeeNo,Sv_EmployeeNo2 \r\n".
                        "FROM AuthorizationRequests \r\n".
                        "WHERE ARNO IN (".$ar_requestno.") ";   
        $result = odbc_do($connectionstring, $query);
        while(odbc_fetch_row($result)){
            $svemp1 = odbc_result($result,1);
            $svemp2 = odbc_result($result,2);
            switch(intval($s)){         
                case 1: // approved 
                        if(empty($svemp1) and empty($svemp2)){
                            $update_fields = "flag=0, DateApproved = { d '".date('Y-m-d')."' } , SV_EmployeeNo=".$_SESSION['uen']." ";
                            $update_query =   "UPDATE AuthorizationRequests \r\n".
                                              "SET ".$update_fields."\r\n ".
                                              "WHERE ArNo IN(".$ar_requestno.")";
                            $update_query = odbc_exec($connectionstring, $update_query);
                            odbc_close($connectionstring);                              
                        }else if(!empty($svemp1) and empty($svemp2) and $svemp1 != $_SESSION['uen']){
                            $update_fields = "flag=".$s.", DateApproved2 = { d '".date('Y-m-d')."' } , SV_EmployeeNo2=".$_SESSION['uen']." ";                            
                            $update_query =   "UPDATE AuthorizationRequests \r\n".
                                              "SET ".$update_fields."\r\n ".
                                              "WHERE ArNo IN(".$ar_requestno.")";
                            $update_query = odbc_exec($connectionstring, $update_query);
                            odbc_close($connectionstring); 
                        }
                    #}                
                    break;
                case 2: // rejected
                        $update_fields = "flag=".$s.", DateApproved = { d '".date('Y-m-d')."' }, SV_EmployeeNo=".$_SESSION['uen']." ";
                        $update_query =   "UPDATE AuthorizationRequests \r\n".
                                          "SET ".$update_fields."\r\n ".
                                          "WHERE ArNo IN(".$ar_requestno.")";
                        $update_query = odbc_exec($connectionstring, $update_query);
                        odbc_close($connectionstring); 
                    break;
                default: // reset
                        $update_fields = "flag=0, DateApproved=NULL, SV_EmployeeNo=NULL, DateApproved2=NULL, SV_EmployeeNo2=NULL";
                        $update_query =   "UPDATE AuthorizationRequests \r\n".
                                          "SET ".$update_fields."\r\n ".
                                          "WHERE ArNo IN(".$ar_requestno.")";
                        $update_query = odbc_exec($connectionstring, $update_query);
                        odbc_close($connectionstring); 
                    break;
            }   
        }

1 个答案:

答案 0 :(得分:1)

使用条件

 $result = odbc_do($connectionstring, $query);

if($result)
{

        while(odbc_fetch_row($result)){

         }
}