Jump to content


Photo

login


  • Please log in to reply
3 replies to this topic

#1 4hana

4hana
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 March 2006 - 11:59 AM

Hi

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:

<?php

// database connect script.

require 'dbconnect.php';

if($logged_in == 1) {
die('You are already logged in, '.$_SESSION['username'].'.');
}


?>

<html>
<head>
<title>Login</title>
</head>
<body>
<?php

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'];
$db_object->disconnect();
?>

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

<A HREF="http://igor.gold.ac....<h3>Relations</
h3></center></A>
<center><h3>Please Click relations to access the database relations index.</center></h3>
<br><hr>


<?php

} else { // if form hasnt been submitted

?>
<h1>Login</h1>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="40">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="s_password" maxlength="50">
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}
?>
</body>
</html>

Any help would be much appreciated.

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 01 March 2006 - 12:49 PM

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

with

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

I think your problem was u used query instead of mysql_query..
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 4hana

4hana
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 March 2006 - 12:55 PM

Hi

Thanks for your help, i replaced the code but i still get the same error.

Fatal error: Call to a member function mysql_query() on a non-object in on line 37



#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 01 March 2006 - 01:41 PM

Are the mysql libarys installed on the machine? because it sounds like a possible problem with that.. can you create a page called phpinfo.php and just put this code in

<?php
php_info();
?>

and then look to see what it says in MySQL area.. if it's not there then that means MySQL is not installed properly
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users