Jump to content

Projeto Pap urgente


Rebimbas

Recommended Posts

Fatal error: Call to a member function fetch_array() on a non-object in C:\xampp\htdocs\Site\conectdb\BaseDados\index.php on line 23

 

Tenho tido este erro apos me registar no site e qaundo vou para fazer o login apos introduzir o email e a pw clico no botão "LOGIN" e enviam-me este erro. 

A minha linha 23 é esta:       $row=$query->fetch_array();

O restante codigo é este:

 

if (isset($_POST['btn-login'])) {
    

    $email = strip_tags($_POST['email']);
    $password = strip_tags($_POST['password']);
    
    $email = $DBcon->real_escape_string($email);
    $password = $DBcon->real_escape_string($password);
    
    $query = $DBcon->query("SELECT name, email, password FROM login WHERE email='$email'");
    $row=$query->fetch_array();
    
    $count = $query->num_rows; // if email/password are correct returns must be 1 row
    
    if ($row['password']) {
        $_SESSION['userSession'] = $row['user_id'];
        header("Location: home.php");
    } else {
        $msg = "<div class='alert alert-danger'>
                    <span class='glyphicon glyphicon-info-sign'></span> &nbsp; Invalid Username or Password !
                </div>";
    }
    $DBcon->close();
}
?>

 

Gostava imenso que me dessem alguma possível solução para este problema que me atormenta a mesmo muito tempo pois no que toca a php eu n estou la muito in nessa matéria.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.