Possible Duplicate:
Call to a member function query() on a non-object in query()?
I am getting the
Fatal error: Call to a member function query() on a non-object Error when trying to get row count from an Account table in my database. Here is the code:
$link = mysqli_connect("localhost", "Username", "Password", "Database");
if ($result = $mysqli->query($link, "SELECT * FROM Accounts WHERE Username=" . $_POST['EmailTbx'] . " AND Password=" . $_POST['PasswordTbx'] . "")){
$field_cnt = $result->field_count;
echo $field_cnt;
$result->close();
}
$mysqli->close();
Your MySQLi object is
$link
here. Not$mysqli
. So either useor
This is the procudural version
It looks like you got your variables mixed up. Try the following (does not prevent injection):
Try the following with escaping: