I have a multi-page webform. I get the above error when I "Save Draft" on Page 1.

Along with the above error, I also get the below error:
warning: mysql_real_escape_string() expects parameter 1 to be string, array given in public_html/test/includes/database.mysql.inc on line 321.

It looks like multi-select fields (i.e. more than one checkbox can be checked) are causing the problem. I am saying that because the error goes away if I remove the only multi-select field on page 1. Also, the error-pair (the two errors above) appears as many times as there are multi-select fields on page 1. For example, I moved a multi-select field from page 2 to page 1 so page 1 now has two multi-select fields. When I "Save Draft" on page 1 with two multi-select fields now, the error pair appears twice.

Comments

kamgd’s picture

Category: support » bug
kamgd’s picture

I have more to add based on further testing. I suspect this could be an issue with the "Select (or other)" module based on my observations below, so I have posted this as an issue there as well.

The error-pair (the two errors above) goes away if I don't set the field for the "Other" option (i.e) uncheck Allow "Other..." option for the field. Also, the error-pair (the two errors above) appears as many times as there are multi-select fields that have Allow "Other..." option checked on page 1. For example, if there are two such fields on page 1, I get the following errors when I "Save Draft".

warning: Illegal offset type in isset or empty in /home/YYYYY/public_html/test/sites/all/modules/webform/components/select.inc on line 480.
warning: Illegal offset type in isset or empty in /home/YYYYY/public_html/test/sites/all/modules/webform/components/select.inc on line 480.
warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/YYYYY/public_html/test/includes/database.mysql.inc on line 321.
warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/YYYYY/public_html/test/includes/database.mysql.inc on line 321.

I don't face this problem with submitting a single page Webform. I face it only when I "Save Draft" on Page 1 in a multi-page form.

I initially thought that is an issue with the "Webform" module but I now think it is a problem with the the "Select (or other)" given my observations above.

Thanks in advance for any help!

kamgd’s picture

I just got a response from "Select(or other)" module maintainer that the problem is happening in a particular use case for webform- http://drupal.org/node/976260

I am wondering if someone can help me with this issue here.

Thanks in advance for any help!

dgastudio’s picture

same problem, for now solved removing

&& isset($options[$option_value])
from select.inc

kamgd’s picture

Thanks for providing this fix. I tested this but I encounter the following error when I click "Save Draft" on Page 1.

warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/YYYYY/public_html/includes/database.mysql.inc on line 321.

I get as many of these errors as there are "multi-select" questions on the page.

I don't get this error when I click "Next Page" but only when I click "Save Draft".

Appreciate any help you or the community may be able to provide!

quicksketch’s picture

Title: warning: Illegal offset type in isset or empty in /public_html/sites/all/modules/webform/components/select.inc on line 480 » warning: Illegal offset type in isset or empty when using "Save draft" button with Select or Other...
Version: 6.x-3.4 » 6.x-3.6
Priority: Major » Normal

Thanks for the reports guys, I've confirmed this issue in the latest version of Webform. I've updated the title of the issue to reflect when the problem occurs more accurately.

dgastudio’s picture

so, any update on this?

quicksketch’s picture

No.

quicksketch’s picture

Version: 6.x-3.6 » 6.x-3.9
Status: Active » Fixed
StatusFileSize
new3.58 KB
new3.58 KB

This patch fixes several problems with select or other:

- Values are maintained when going "Back" and "Next" on a submission when the page contains a Select or Other field.
- The Back button allows going backward when a Select or Other field is on the current page.
- The "Save Draft" functionality works when a Select or Other field is on the current page.

Considering the number of fixes and no apparent downside, I've committed these patches to the 3.x branches.

dgastudio’s picture

i can't apply the d6 version patch to version 3.9!

as i can see, this patch is for 3.dev version!

quicksketch’s picture

I wouldn't expect you would be able to be able to apply the patch directly, as I've gone through over 50 patches in the last 2 weeks. You should try downloading the development version after 24 hours or doing a checkout from Git. I plan on releasing 3.10 on Wednesday, May 18th, but I'd definitely appreciate it if you could check out the latest code and post any troubles you have (hopefully as new issues or corresponding to the appropriate one).

dgastudio’s picture

ok, thank u very much!

markabur’s picture

In the Drupal 7 version of Select or Other, the function is select_or_other_element_process(), not select_or_other_process() -- see #1167286: Fatal error: Call to undefined function select_or_other_process() in (...)/includes/form.inc on line 1723

quicksketch’s picture

Thanks markabur. Indeed I didn't check select_or_other in Drupal 7 at the time because it doesn't yet have any usable version as far as I know.

Jerome F’s picture

issue pointed in #13 fixed in webform's last git

toabi’s picture

Version: 6.x-3.9 » 7.x-3.x-dev
Status: Fixed » Patch (to be ported)
StatusFileSize
new1.06 KB

These changes still break the D7 version of select_or_other here: #1167286: Fatal error: Call to undefined function select_or_other_process() in (...)/includes/form.inc on line 1723

Although Jerome F. wrote there, that this is fixed in last webform git, it is not: http://drupalcode.org/project/webform.git/blob/HEAD:/components/select.i...

The attached patch should resolve the issue.

enap’s picture

Confirming #16 fixes the issue using D7.2, Webform 3.11 & Select or Other 2.0 (as per error in #13).

Jerome F’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

My mistake, I used the git version 7.x-3.9-hotfix for my comment in #15 and your patch is against master.
The patch fixes the issue, thank you.

this patch is not commited to D7 yet, so I change the status accordingly
http://drupal.org/node/156119 :
Patch (to be ported)
The patch has been successfully committed to a branch of the project, and still needs to be committed to another, but the current patch doesn't apply to the target branch and needs to be modified in order to do so.

quicksketch’s picture

Thanks guys, I'll get this in next time I'm working on Webform.

webankit’s picture

+1

nardberjean’s picture

I understand it may be fixed in webform 7.x-3.12, good to know.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Committed patch from #16. Thanks toabi and all the testers!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

siliconmind’s picture

Version: 7.x-3.x-dev » 6.x-3.9
Status: Closed (fixed) » Active

This issue is marked as fixed, but I'm experiencing similar problem with "Illegal offset type" error. I'm using webform 6.x-3.9 and select_or_other 6.x-2.9 which are the latest.

I'm getting Warning: Illegal offset type in isset or empty in select.inc on line 510.
The variable $option_value in _webform_submit_select is sometimes an array and that causes error on line 510.

markabur’s picture

Version: 6.x-3.9 » 7.x-3.x-dev
Status: Active » Fixed

@SiliconMind the latest version of Webform is actually 6.x-3.14 -- you're right that 6.x-3.9 doesn't contain the fix.

siliconmind’s picture

Version: 7.x-3.x-dev » 6.x-3.14
Priority: Normal » Major
Status: Fixed » Active

@markabur, I made a mistake writing down webform version. Actually I'm using 3.14 and am still getting this error.
Aside from error on line 510 of select.inc, when I click "< Previous Page" the values from previous selection are not checked by default, but instead "Other" field is active and all values, comma separated, are put there.

markabur’s picture

Version: 6.x-3.14 » 7.x-3.x-dev
Status: Active » Fixed

Sorry, sounds like you're having a totally different problem than the one in the original post -- please open a separate issue for it so that it can be fixed separately (even if it was related to this issue, at this point a separate followup issue would be better anyway).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.