preferences.php fixes

mysql --> mysqli
Now using prepared statements to prevent sql injection.
Fixed many errors.
Note: There is still some kind of bug with GMT >9 && <-9