0

i have problem when i run blow query if don't find any thing show this error

EX ERROR=>SQLSTATE[HY000] [1045] Access denied for user 'mehran'@'localhost' (using password: YES) Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\myproject\article_project\DB_operation\DB_signin.php on line 16

try {
    $account_id = 0;

    $conn = dbconnection();



    $query = "select * from account WHERE email= :email and password=:password";
    $stmt = $conn->prepare($query);

    $stmt->bindParam(':email', $email);
    $stmt->bindParam(':password', $password);
    $stmt->execute();

    while ($row = $stmt->fetchObject()) {
        $account_id = $row->id;
    }

    if ($account_id > 0) {
        $query = "select * from account_detail WHERE account_id= :account_id ";
        $stmt = $conn->prepare($query);

        $stmt->bindParam(':account_id', $account_id);
        $stmt->execute();

        while ($row = $stmt->fetchObject()) {
            $id = $row->id;
            $firstname = $row->firstname;
            $lastname = $row->lastname;
            $access = $row->access;
        }

        $_SESSION['id'] = $id;
        $_SESSION['firstname'] = $firstname;
        $_SESSION['lastname']=$lastname;
        $_SESSION['access']=$access;


    } else {
        $_SESSION['error'] = "user not found";
    }
aynber
  • 22,380
  • 8
  • 50
  • 63
mehran
  • 1

0 Answers0