You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and institucion_codigo=' at line 1->SELECT beca_codigo from beca where beca_clave = '' and taller_codigo = and institucion_codigo=