update mysql function to mysqli