If you are getting this error:
Internal SQL Bug: 2014, Commands out of sync; you can't run this command now
Then you never called mysqli_result::free(), mysqli_result::free_result(), mysqli_result::close(), or mysqli_free_result() in your script, and must call it before executing another stored procedure.