odbc_exec():SQL错误:[Microsoft] [ODBC Microsoft Access驱动程序]条件表达式中的数据类型不匹配。,SQLExecDirect中的SQL状态22005

时间:2018-01-21 10:38:26

标签: php database odbc ms-access-2007

使用ODBC在PHP中获取数据Microsoft Access数据库。当Run Query Execute然后给出错误:

  

odbc_exec():SQL错误:[Microsoft] [ODBC Microsoft Access驱动程序]数据   标准表达式中的类型不匹配。,SQL状态22005 in   第21行的C:\ xampp \ htdocs \ Project1 \ Attend.php中的SQLExecDirect

Connection.php运行给Message Connect。当$stmt = odbc_exec($conn, $sql)运行时,给出上述警告。什么问题我没有。

Connection.php

<?php

$conn = odbc_connect("$dbq","",""); 
if($conn){
    echo "Connected";

}else{

    echo "Failed";
}
?>

Attend.php

<?php

include 'Connection.php';

if(isset($_REQUEST["insert"]))
{
    $reg = $_GET['reg'];
    $ID = $_GET['ID'];

    $sql = "select a.RegNo,b.RollNo,c.Standard,d.Division,b.Std_Name as StudentName,AttendanceDate,Attendance_Type,Remark
                                         from (((Attendance_mas as a 
                                         inner join Std_Reg as b on a.RegNo = b.RegNo) 
                                         inner join StandardMaster as c on a.Standard = c.stdid)
                                         inner join DivisionMaster as d on a.Division =d.DivisionID)
                                         where a.RegNo= '$reg' and a.yearid = '$ID' Order by AttendanceDate desc";
    //$sql = "select * from Std_Reg";

    $stmt = odbc_exec($conn, $sql);
    //print_r($stmt);
    $result = [];
    do {
        while ($row = odbc_fetch_array($stmt)){
           $result[] = $row; 
        }
    } while (odbc_next_result($stmt));

    if(count($result)>0)
    {
        $result1['status']=1;//"Login successfully";
        array_push($result1,$result);
    }
    else
    {
         //$result[]="null";
        $result1['status']=0;//"Record not found";
        array_push($result1,$result);
    }
    odbc_free_result($stmt);
    odbc_close($conn); //Close the connnectiokn first

    echo json_encode($result1); //You will get the encoded array variable
}

?>

0 个答案:

没有答案