Updated the functions in phpscript to mysqli