You have to ensure you are using a variable in a section loop. For example:
Code:
{section name=prod_num loop=$products}
{$products[prod_num].product}: {$products[prod_num].categoryid}<br />
{/section}
Not sure if the categoryid is in the cart $products variable as I didn't test it.