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 ') and (dat_isenable=1 or (dat_isenable='2' and TO_DAYS(dat_ondate)<=TO_DAYS(...' at line 1
select * from data where dat_no='115' and (dat_months='13' or ) and (dat_isenable=1 or (dat_isenable='2' and TO_DAYS(dat_ondate)<=TO_DAYS(CURDATE()) and TO_DAYS(dat_offdate)>=TO_DAYS(CURDATE())))