Problem posting <select> multiple value
3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 29, 2011 (RSS)
Hello,
We're attempting to have include a multi-select input value on a user signup page form (using the Website Membership plugin). I receive the following error when submitting:
Warning: strtr() expects parameter 1 to be string, array given in /home/cploan/public_html/admin/lib/database_functions.php on line 21
We're attempting to POST the multiple selections as an array to be added (and our form field structure appears to be identical to the one used in the CMSB admin area), and it seems the mysql_escape function wants to treat the array as a string. Is there a special flag we need to use to call a different "strip" function for this field value?
You can see the signup page at the link below:
http://208.79.239.28/~cploan/login/user-signup.php
Thanks in advance for your help.
Dennis O'Neil
We're attempting to have include a multi-select input value on a user signup page form (using the Website Membership plugin). I receive the following error when submitting:
Warning: strtr() expects parameter 1 to be string, array given in /home/cploan/public_html/admin/lib/database_functions.php on line 21
We're attempting to POST the multiple selections as an array to be added (and our form field structure appears to be identical to the one used in the CMSB admin area), and it seems the mysql_escape function wants to treat the array as a string. Is there a special flag we need to use to call a different "strip" function for this field value?
You can see the signup page at the link below:
http://208.79.239.28/~cploan/login/user-signup.php
Thanks in advance for your help.
Dennis O'Neil
Re: [dennisoneil] Problem posting <select> multiple value
By Jason - December 29, 2011
Hi Dennis,
In CMS Builder, multi-select lists are stored as a string separated by tab (\t) characters. So what you need to do is to take your array and turn it into a tab separated string.
For example:
You can then use the variable $territory in your INSERT statement.
Hope this helps
In CMS Builder, multi-select lists are stored as a string separated by tab (\t) characters. So what you need to do is to take your array and turn it into a tab separated string.
For example:
if (is_array($_REQUEST['territory'])) {
$territory = mysql_escape("\t".join("\t", @$_REQUEST['territory'])."\t");
}
else {
$territory = "";
}
You can then use the variable $territory in your INSERT statement.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Problem posting <select> multiple value
Worked perfectly. Thanks Jason.