Check user’s role and store in variable

You don’t need to store anything, just check the current logged in user via user_can:

global $current_user;
get_currentuserinfo();
if ( user_can( $current_user, "role_apple" ) ){
  // do something
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)