Posted: 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 |
|
|
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 |
The event is there but inactive |
|
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. |
|
Alright, thank you. So the update is in /plugins/event-espresso/includes/admin-reports/edit_attendee_record.php |
|
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 |
|
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. |
|
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. |
|
Any “Closed” or old event, we cannot update anything for any attendee… |
|
Hi Al, We can assist if you’re having this issue on an unmodified, current version of Event Espresso. |
|
Nothing regarding that page has been modified though. |
|
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. |
|
|
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). |
I just did a diff. The live / dev edit_attendee_record.php file is exactly the same. |
|
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.
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? |
|
Hi, so now we are not running 3.1.36.4.P. 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”. |
|
Might be different versions of MySQL installed on your dev server compared to your live server. |
|
Hi Josh, but if the query being sent is empty that shouldn’t make a difference though? |
|
Both PHP versions and MySQL versions are different. Our Dev (that is working) is older, and live (not working) is newer versions. |
|
|
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. |
So just var_dump( $x ) where x is the sql query? |
|
|
Yes, that’s correct |
So here is what came of it; DEV LIVE 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. |
|
So I went up to the line that declares 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. |
|
|
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). |
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.