Support

Home Forums Event Espresso Premium SQL Error when updated Attendee Notes

SQL Error when updated Attendee Notes

Posted: January 27, 2014 at 10:23 am

Viewing 23 reply threads


Al Joly

January 27, 2014 at 10:23 am

We are receiving an SQL error when attempting to update an attendee’s notes.

We have determined that this error only occurs when we are attempting to update a note in a record for an inactive event. Also, it has only started occurring lately (in the last week). Since we frequently have a need to update records for past students, there is some urgency in resolving the issue.

Here is the message:

Warning: Invalid argument supplied for foreach() in /home/firstaid/public_html/wp-content/plugins/event-espresso/includes/admin-reports/edit_attendee_record.php on line 300
WordPress database error: [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 (at.attendee_id IS NULL OR at.attendee_id = ‘32885’) ORDER BY qg.id, q.id ‘ at line 1]
SELECT q.*, q.id AS q_id, at.id AS a_id, at.*, qg.group_name, qg.show_group_description, qg.show_group_name FROM wp_events_question q LEFT JOIN wp_events_answer at on q.id = at.question_id JOIN wp_events_qst_group_rel qgr on q.id = qgr.question_id JOIN wp_events_qst_group qg on qg.id = qgr.group_id WHERE qgr.group_id in ( ) AND (at.attendee_id IS NULL OR at.attendee_id = ‘32885’) ORDER BY qg.id, q.id ASC


Sidney Harrell

January 27, 2014 at 10:42 am

Is the event inactive or gone from the database completely? It is looking for the questions that are assigned to the event that the attendee is signed up for. I looks like as long as the event is still in the
DB, it should be ok. If it is gone from the DB, you may need to create a placeholder event, reassign the id of it in the DB to the id of the event that those attendees are assigned to.


Al Joly

January 27, 2014 at 1:17 pm

The event is there but inactive


Josh

  • Support Staff

January 28, 2014 at 8:46 am

Hi Al,

The query that you posted the error from has been updated in a recent version to fix some related issues. You can review the changes that were made to it if you download the latest version of Event Espresso and look at the changes to the query on line 315.


Al Joly

January 28, 2014 at 9:36 am

Alright, thank you.

So the update is in

/plugins/event-espresso/includes/admin-reports/edit_attendee_record.php
Line 315 in the SQL query??


Al Joly

January 28, 2014 at 10:01 am

Hi Josh,

I attempted to modify the SQL to match the newest Version, but still provided error. I then tested it by replacing the whole file with the new one and still an error, different, but still an error:

Warning: Invalid argument supplied for foreach() in /home/firstaid/public_html/wp-content/plugins/event-espresso/includes/admin-reports/edit_attendee_record.php on line 302
WordPress database error: [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 ‘) ORDER BY qg.id, q.id ASC’ at line 1]
SELECT q.*, q.id AS q_id, qg.group_name, qg.show_group_description, qg.show_group_name FROM wp_events_question q JOIN wp_events_qst_group_rel qgr on q.id = qgr.question_id JOIN wp_events_qst_group qg on qg.id = qgr.group_id WHERE qgr.group_id in ( ) ORDER BY qg.id, q.id ASC


Josh

  • Support Staff

January 28, 2014 at 12:26 pm

Hi Al,

I think what you’ll need to try is set up a clone of your site and run an unmodified copy of the latest version of Event Espresso installed on it. If you get the same errors on the dev site, please send an export of the database and we can take a look.


Al Joly

January 28, 2014 at 12:49 pm

This is now restricting us from updating any information. I really need assistance with this … I really do not understand how all of a sudden this starts happening. Nothing like this happened until like a week ago.


Al Joly

January 28, 2014 at 1:01 pm

Any “Closed” or old event, we cannot update anything for any attendee…


Josh

  • Support Staff

January 28, 2014 at 1:05 pm

Hi Al,

We can assist if you’re having this issue on an unmodified, current version of Event Espresso.


Al Joly

January 28, 2014 at 1:31 pm

Nothing regarding that page has been modified though.


Al Joly

January 28, 2014 at 1:32 pm

I have a clone of it running on another server as well. I’ve provided access before. But that version does not seem to have this same issue. Is it possible that the server changed?? That owuld in fact explain why the issue has arisen in the past week.


Dean

January 29, 2014 at 5:37 am

Hi,

Unless you own and control the server then yes server changes are very much a possibility. I would speak to your host to clarify if any changes have been made recently and if so what they are.

You may also want to try a “diff” on the event espresso files on the live server versus the clone server to see if there have been modifications made recently that haven’t been accounted for (and possibly causing the issue).


Al Joly

January 29, 2014 at 2:09 pm

I just did a diff. The live / dev edit_attendee_record.php file is exactly the same.


Tony

  • Support Staff

January 30, 2014 at 2:25 am

Hi Al,

So currently is the edit_attendee_record.php on the server the same as the latest version of Event Espresso? (which currently is 3.1.36.4)

Reason I ask, is the Line numbers do no match with the version I have.

The reason the SQL is failing is $question_id is not being set. You can see this from this part of the SQL

'WHERE qgr.group_id in ( ) ORDER BY'

So in slightly better english ‘WHERE qgr.group_id is in “nothing”‘.

$question_id should be set on lines 291 – 305

$SQL = "SELECT question_groups, event_meta FROM " . EVENTS_DETAIL_TABLE . " WHERE id = %d";
$questions = $wpdb->get_row( $wpdb->prepare( $SQL, $event_id ));

$question_groups = unserialize($questions->question_groups);
			$event_meta = unserialize($questions->event_meta);

if ( $is_additional_attendee && isset($event_meta['add_attendee_question_groups']) && $event_meta['add_attendee_question_groups'] != NULL) {
	$question_groups = $event_meta['add_attendee_question_groups'];
}

$questions_in = '';
foreach ($question_groups as $g_id ) {
	$questions_in .= $g_id . ',';
}
$questions_in = substr($questions_in, 0, -1);

There is no check if the event is active, it just pulls all question_groups and event_meta from the events table where the event_id matches.

So it looks like that is returning nothing, which should never happen (as you should always have at least personal information (so at least 1 question group))

So something has changed with either/and/or questions, question groups, event_meta or the event_id.

Nothing regarding that page has been modified though.

If its the questions/question_groups it does’t need to be within this page. It could be almost anywhere that the questions/groups are updated.

Unfortunately as this is a modified version of Event Espresso (also with updates from current versions), that’s about as much info as we can give you as we just don’t know what has been changed, and the knock on effect of any changes that have been made.

The question groups may also be a red herring if changes are made when events become inactive/expired (as that seems to be the only time you have an issue) but that SQL above doesn’t look at the event status.

Have you tried temporarily making the event active and edit the record to see if it update then?


Al Joly

January 30, 2014 at 2:16 pm

Hi, so now we are not running 3.1.36.4.P.
But I did take that file from 3.1.36.4.P and put it live and we still received the error.

The odd thing (to me) is that this error does not show up on our development server which is a clone.

You have mentioned the question/question groups, so could it possibly be something in the database? I thought the same thing so I took the live database and put it onto our dev site and tested it and it still updates fine on our development server. So I am quite puzzled.

Just reviewed the active/inactive. So it is “Active”, but the status is “Closed”.


Josh

  • Support Staff

January 30, 2014 at 2:34 pm

Might be different versions of MySQL installed on your dev server compared to your live server.


Al Joly

February 3, 2014 at 1:46 pm

Hi Josh, but if the query being sent is empty that shouldn’t make a difference though?


Al Joly

February 3, 2014 at 1:50 pm

Both PHP versions and MySQL versions are different. Our Dev (that is working) is older, and live (not working) is newer versions.


Sidney Harrell

February 3, 2014 at 3:50 pm

You might want to do a var_dump of the query that is failing, copy and paste it into phpMyAdmin and run it there. Sometimes it is a lot easier to see why a query has failed when you are running it there.


Al Joly

February 3, 2014 at 6:00 pm

So just var_dump( $x ) where x is the sql query?


Dean

February 4, 2014 at 12:33 am

Yes, that’s correct


Al Joly

February 4, 2014 at 3:37 pm

So here is what came of it;

DEV
string(408) “SELECT q.*, q.id AS q_id, at.id AS a_id, at.*, qg.group_name, qg.show_group_description, qg.show_group_name FROM wp_events_question q LEFT JOIN wp_events_answer at on q.id = at.question_id JOIN wp_events_qst_group_rel qgr on q.id = qgr.question_id JOIN wp_events_qst_group qg on qg.id = qgr.group_id WHERE qgr.group_id in ( 1,4 ) AND (at.attendee_id IS NULL OR at.attendee_id = ‘%d’) ORDER BY qg.id, q.id ASC”

LIVE
string(405) “SELECT q.*, q.id AS q_id, at.id AS a_id, at.*, qg.group_name, qg.show_group_description, qg.show_group_name FROM wp_events_question q LEFT JOIN wp_events_answer at on q.id = at.question_id JOIN wp_events_qst_group_rel qgr on q.id = qgr.question_id JOIN wp_events_qst_group qg on qg.id = qgr.group_id WHERE qgr.group_id in ( ) AND (at.attendee_id IS NULL OR at.attendee_id = ‘%d’) ORDER BY qg.id, q.id ASC”

It appears that the ‘WHERE qgr.group_id in ( )’ is blank on live but there in DEV. So then I tried to print_r on the question group ID stuff. So I went to line about 290 and print_r($event_id), on dev it is 454, on live, nothing shows.

I then moved down to line 292 and print_r($question_groups), on dev it is an array with 1 and 4, then on live it is empty.

This is the 1,4 that show in the above query on dev but not on live. So how is it that the website cannot pull these details on the live website? I copied the database from the live site, to dev, and this is still happening. It seems so weird with an exact replica database.


Al Joly

February 4, 2014 at 3:49 pm

So I went up to the line that declares event_id
Line 204 $event_id = isset($_POST[‘event_id’]) ? $_POST[‘event_id’] : ”;

For some reason, it wasn’t getting the value, so it was blank. I checked and seen that this value was passed via get as well. So I changed the query to this:

$event_id = isset($_POST[‘event_id’]) ? $_POST[‘event_id’] : $_GET[‘event_id’];

And now it works with no error. I would love to know your thoughts.


Sidney Harrell

February 4, 2014 at 3:51 pm

The event id is set in the POST of the form. Do an element inspect on the ‘Update Record’ button. Above the button there should be a hidden input with name=’event_id’. Should be generated by line 664 of includes/admin-reports/edit_attendee_record.php (current version).

Viewing 23 reply threads

The support post ‘SQL Error when updated Attendee Notes’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso