Jump to content
MakeWebGames

Fatal errCall to a member function query() on a non-objec


Recommended Posts

Posted

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.

[syntax=php]

<?

//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();

[/syntax]

line 42 is $query = $db->query

[syntax=php]//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']);

}

}[/syntax]

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...