You are creating the COMMID session variable after the recordset4 code.
PHP code is executed from top to bottom, for the recordset4 recordset to be able to filter on the COMMID session variable, the COMMID session variable must be created before the recordset4 recordset.