-2

嗨,我正在就上述问题 LINE 66 寻求一些帮助。我可以看到有几个 mysql 用户遇到了与我相同的问题,但在尝试了解决方案之后,似乎错误仍然存​​在。这是我的代码。

check_login.php

    if(isset($_POST['submit']) && !empty($_POST['submit']))

{

    $stmt2= oci_parse($conn, "SELECT * FROM user1 WHERE id = '".$_POST['id']."' ")or die(oci_error());
    $check2 = oci_execute($stmt2);

         //Gives error if user dosen't exist
     //$check3 = oci_num_rows($check2); <-- if I uncomment this, it will result in an error too.

       if (!$check2) //it supposely if($check3<0)
       {
       header('location: index.php?error=10');
            exit();
       }
       else
       {
        while($info2=oci_fetch_array($check2)) // <----- Error in this line (line 66).
            {
            $pass=$info2['password'];
            //gives error if the password is wrong
            if ($_POST['password'] != $pass)
            {
            header('location: index.php?error=14');
            exit();
            }
            else
            {

             // if login is ok then we add a cookie
            $_SESSION['id'] = $_POST['id'];
            $_SESSION['password'] = $_POST['password'];
        $hour = time() + 86400;

            setcookie(ID_site, $_SESSION['id'], $hour);
            setcookie(Pass_site, $_SESSION['password'], $hour);

            //then redirect them to the members area
                if ($info2['role']=='admin')
                {
                header('Location: homeAdmin.php');
                }
                elseif ($info2['role']=='staff')
                {
                header('Location: homeStaff.php');
                }
                elseif ($info2['role']=='student')
                {
                header('Location: homeStudent.php');
                }
                else
                {
                header('Location: index.php');
                }

            } //end else

         } //end while

}//end else

}// end if submit
 else
{
 header('Location: index.php');
 } 
4

1 回答 1

1

oci_execute 总是返回一个布尔值。基本上,oci_execute 返回 db 语句是否有效,但它会将语句的结果存储回最初保存该语句的传递变量中。因此,如果您将错误行更改为此,您应该没问题:

while ($row = oci_fetch_array($stmt2, OCI_ASSOC+OCI_RETURN_NULLS)) {
于 2013-09-10T04:02:06.787 回答