How to work around case sensitivity of HEX values?

This is more basic PHP than WordPress, but you can do a case insensitive search using strcasecmp().

if ( strcasecmp( $bg, '#F5F5F5' ) != 0 ) {
  $cssoutput .= "body { background-color: " . $bg . "; } \n";
}

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