Fatal error: Call to a member function prepare() on a non-object

lovingun -  
jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   -
Hello i made a website and i have a problem in Login.php and Register.php !! It's the same.

PROBLEM IS IN THE LINE N°6 : Fatal error: Call to a member function prepare() on a non-object in /home/a7278696/public_html/login.php on line 111

    {
$errors[] = 'Please fill in all fields';
}

if (empty($errors))
{
$SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username AND `password` = :password");
$SQLCheckLogin -> execute(array(':username' => $username, ':password' => SHA1($password)));
$countLogin = $SQLCheckLogin -> fetchColumn(0);
if ($countLogin == 1)
{
$SQLGetInfo = $odb -> prepare("SELECT `username`, `ID`, `status` FROM `users` WHERE `username` = :username AND `password` = :password");
$SQLGetInfo -> execute(array(':username' => $username, ':password' => SHA1($password)));
$userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
if ($userInfo['status'] == "0")
{
$_SESSION['username'] = $userInfo['username'];
$_SESSION['ID'] = $userInfo['ID'];

$ip = getRealIpAddr();
$SQL = $odb -> prepare('INSERT INTO `loginlogs` VALUES(:username, :ip, UNIX_TIMESTAMP(), "")');
$SQL -> execute(array(':ip' => $ip, ':username' => $username));
echo '<div class="alert alert-success"><center><p><font color=\'black\'>Login Succeed. Redirecting....</font></p></center></div><meta http-equiv="refresh" content="3;url=index.php">';
die();

}

3 réponses

  1. ThEBiShOp Messages postés 9307 Date d'inscription   Statut Contributeur Dernière intervention   1 606
     
    Hello,

    my guess is that your $odb object has not been properly instantiated...
    I can't tell since you are not showing us where it came from.
    0
  2. lovingun
     
    just tell me what should i give you
    0