Changed all mysql functions to mysqli