db_query('SELECT nid FROM uc_products'); doesn't give any results! Why?
I think it is likely because your first result is a "0" and php will evaluate that as a False, which stops your while loop from running.