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 'OR profesor_2 = OR profesor_3 = ) ...' at line 20
: SELECT d.*, case when e.id_curso_original is null then e.id else e.id_curso_original end as id_curso_original, p.instagram, p.mostrar_foto_en_cursos, p.foto as profesor_foto FROM ed_cursos d left join co_cursos_ediciones e on e.id_curso = d.id left join ed_profesores p on p.id = d.profesor_1 WHERE 1=1 and d.oculto = 0 and ( fecha_inicio > now() OR fecha_inicio = "0000-00-00 00:00:00" OR mostrar_hasta >= date(now()) ) and (profesor_1 = OR profesor_2 = OR profesor_3 = ) and d.modalidad = 'online' ORDER BY case when fecha_inicio like '0000-00-00%' or fecha_inicio <= now() then '2030-01-01 00:00:00' else fecha_inicio end, rand()