MySQL Stored Procedure in PHP gotcha

If you're getting a 'Commands out of sync' message after calling a Stored Procedure in MySQL 5+, it means there's some empty resultset in still in the resultset buffer. I'm not sure exactly why this is happening, but here's the workaround:

<?php

  // Assuming $connection is your MySQLI object

  while($connection->next_result()) $connection->store_result();

?>