Revert "Replace mysql_* with mysqli_* functions"

This reverts commit af4d30b3e954fc27eb92010f16419529e3903e9f.
Revert "Revert "Replace mysql_* with mysqli_* functions""

This reverts commit 86693b1c8719eca42de9f9e89df90de45c376167.