bugfix.
added small function and correction in procedure.
mysql to mysqli