<b>Fatal errCall to a member function query() on a non-objec
Posted: Fri Feb 04, 2011 7:44 am
How do I workaround this? says error is line 42
here is the begining of my file. The rest is just functions. So i'll show the function that is causing it.
line 42 is $query = $db->query
here is the begining of my file. The rest is just functions. So i'll show the function that is causing it.
Code: Select all
<?
//session stuff
session_start();
//include required files.
include "../config.php";
include "../phpMySQL.php";
include "../includes/constants.php";
//initiate class.
$db = new phpMySQL($dbhost, $dbuser, $dbpass, $dbname);
$db->connect();
Code: Select all
//attempt to login user
function userLogin()
{
//check if username pass string test
if(checkUser() == true && checkPass() == true)
{
//query to check if user name or email in use
$query = $db->query("SELECT userID, userActCode, userRank, COUNT(userID) as counts FROM " . USER_TABLE . "' WHERE userHandle='" . $db->escape($_POST['textUser']) . "' OR userPass='" . $db->escape($_POST['textPass']) . "'");
$rec = $db->fetch_array($query);
//user name and password match
if($rec['counts'] == 1)
{
//user account activated
if($rec['userActCode'] == 0)
{
$_SESSION['userID'] = $rec['userID'];
$_SESSION['userRank'] = $rec['userRank'];
//update last activitity
$data = array("userLastActive" => time());
$db->update(USER_TABLE, $data, "userID='" . $rec['userID'] . "'");
die('Login Successfull, Redirecting...<script type="text/javascript">window.location = "' . $pather . '"</script>');
}
else
{
//display error
die("You must first activate your account...");
}
}
else
{
//display error
die("Incorrect User name and password combination...");
}
}
else
{
//display error
die($_SESSION['msg']);
}
}