Replace old mysql functions with mysqli functions