MySQL Query Problem
- by user559744
Hello guys, I'm getting following error message. Please help me. Thanks
Notice: Trying to get property of non-object in
C:\xampp\htdocs\my\include\user_functions.php on line 34
Here is my Code
$conn = db_connection();
if($conn == false) {
user_error('Unable to connect to database');
return false;
}
$query = "UPDATE user SET passwd = '".$new_passwd."'
WHERE username = '".$username."' ";
$result=$conn->query($query);
if($result == false) {
user_error('Query Error'.$conn->error);
return false;
}
if($result->num_rows == 1) {
echo 'Password changed';
} else {
echo 'Failed ';
}
here is my db_connection
function db_connection() {
$db = new mysqli('localhost','root','','php_login');
if(!$db) {
echo 'Could not connect to database server';
} else {
return $db;
}
}