Machform error: Cardinality violation: 1242 Subquery returns more than 1 row

We have a multiuser Machform PHP application running on a Redhat 7 Linux server with Apache webserver and MariaDB database.

In a specific form after page 3, accessing this URI: confirm.php?id=NNNNNNNN&mf_page_from=3 where NNNNNNNN is the id number of the form,

The following error message appears:

SQL: [671] select A.element_id, A.option_id, (select if(B.element_matrix_parent_id=0,A.option, (select C.`option` from ap_element_options C where C.element_id=B.element_matrix_parent_id and C.form_id=A.form_id and C.live=1 and C.option_id=A.option_id)) ) ‘option_label’ from ap_element_options A left join ap_form_elements B on (A.element_id=B.element_id and A.form_id=B.form_id) where A.form_id=? and A.live=1 and B.element_type=’matrix’ and B.element_status=1 order by A.element_id,A.option_id asc Sent SQL: [680] select A.element_id, A.option_id, (select if(B.element_matrix_parent_id=0,A.option, (select C.`option` from ap_element_options C where C.element_id=B.element_matrix_parent_id and C.form_id=A.form_id and C.live=1 and C.option_id=A.option_id)) ) ‘option_label’ from ap_element_options A left join ap_form_elements B on (A.element_id=B.element_id and A.form_id=B.form_id) where A.form_id=’NNNNNNNN’ and A.live=1 and B.element_type=’matrix’ and B.element_status=1 order by A.element_id,A.option_id asc Params: 1 Key: Position #0: paramno=0 name=[0] “” is_param=1 param_type=2 Query Failed: SQLSTATE[21000]: Cardinality violation: 1242 Subquery returns more than 1 row

The solution is to change this file:

/includes/entry-functions.php

where line: C.option_id=A.option_id))

is changed to:

C.option_id=A.option_id LIMIT 1))

Leave a Reply

Your email address will not be published. Required fields are marked *