i have a serious problem!
I want to use different values from different tables in my database. My tables:
users
user_id | name | email | password | color | created
parents
parent_id | email | password
So, i want to connect these tables with email col. But passwords cols are different.
Here is my code:
$_SESSION['logged_in2'] = false;
if( !empty( $data ) ){
// Trim all the incoming data:
$trimmed_data = array_map('trim', $data);
// escape variables for security
$email = mysqli_real_escape_string( $this->_con, $trimmed_data['email'] );
$password = mysqli_real_escape_string( $this->_con, $trimmed_data['password'] );
if((!$email) || (!$password) ) {
throw new Exception( PARENTS_FIELDS_MISSING );
}
$password = md5( $password );
$query = "SELECT parent_id, email FROM parents where email = '$email' and password = '$password' union all SELECT name FROM users ";
$result = mysqli_query($this->_con, $query);
$data = mysqli_fetch_assoc($result);
$count = mysqli_num_rows($result);
mysqli_close($this->_con);
if( $count == 1){
$_SESSION = $data;
$_SESSION['logged_in2'] = true;
return true;
}else{
throw new Exception( PARENTS_FAIL );
}
} else{
throw new Exception( PARENTS_FIELDS_MISSING );
}
How can i use these tables in one code? Please help! By the way, the error is this:
mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given