Fixed mysql_real_escape_string

There were two issues related to this.
1. mysql_real_escape_string is deprecated from PHP 5.5.0 onwards
2. The implementation used mysqli functions to connect to the database while mysql_real_escpe to escape the post parameters. The corresponding functions should have been mysqli_ ...

Fixed to use mysqli functions for all mysql calls.