Jump to content


Recommended Posts



I get the following error when i load my login page.


Fatal error: Call to a member function query() on a non-object on line 35


Below is the code:




// database connect script.


  require 'dbconnect.php';


if($logged_in == 1) {

  die('You are already logged in, '.$_SESSION['username'].'.');













if (isset($_POST['submit'])) { // if form has been submitted



  /* check they filled in what they were supposed to and authenticate */

  if(!$_POST['username'] | !$_POST['s_password']) {

      die('You did not fill in a required field.');



  // authenticate.


  if (!get_magic_quotes_gpc()) {

      $_POST['username'] = addslashes($_POST['username']);



  $check = $db_object->query("SELECT username, password FROM student WHERE username = '".$_POST['username']."'");


  if (DB::isError($check)) {

      die('That username does not exist in our database.');



  $info = $check->fetchRow();


  // check passwords match


  $_POST['s_password'] = stripslashes($_POST['s_password']);

  $info['password'] = stripslashes($info['password']);

  $_POST['s_password'] = md5($_POST['s_password']);


  if ($_POST['s_password'] != $info['password']) {

      die('Incorrect password, please try again.');



  // if we get here username and password are correct,

  //register session variables and set last login time.




  $_POST['uname'] = stripslashes($_POST['uname']);

  $_SESSION['username'] = $_POST['username'];

  $_SESSION['password'] = $_POST['s_password'];




<h1>Logged in</h1>

<p>Welcome back <?php echo $_SESSION['username']; ?>, you are logged in.</p>




<center><h3>Please Click relations to access the database relations index.</center></h3>








} else {  // if form hasnt been submitted




<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">

<table align="center" border="1" cellspacing="0" cellpadding="3">


<input type="text" name="username" maxlength="40">



<input type="password" name="s_password" maxlength="50">


<tr><td colspan="2" align="right">

<input type="submit" name="submit" value="Login">










Any help would be much appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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.