Migrate to mysqli

Migrate all mysql to mysqli for apply patch wyth
mysqli_real_escape_string