You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 SQL query : select count(*) from SS_discussions_new WHERE categoryID='1196' OR productID IN (8495,8496,8497,8498,34689,8499,8500,8501,8502,8503,8504,8505,8523,8524,8525,8506,8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517,8518,8519,8520,8521,8522,21167,21168,21169,21170,34690,21171,21172,21173,21174,21175,21176,21193,21194,21195,21177,21178,21179,21180,21181,21182,21183,21184,21185,21186,21187,21188,21189,21190,21191,21192,8526,8527,8528,34691,8529,34692,8530,8531,8532,34693,8533,8534,34694,8535,34695,8536,8537,8538,34696,8539,8540,34697,8541,8542,8543,34698,34699,8544,8545,34700,34701,32944,75994,51165,51166,51167,51168,51169,51170,51171,51172,51173,51174,51175,51176,51177,51178,51179,51180,51181,51182,51183,51186,51187,51188,51189,51190,51191,51192,51193,51194,)