Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Problem posting <select> multiple value

 

 


dennisoneil
User

Dec 29, 2011, 8:39 AM

Post #1 of 3 (247 views)
Shortcut
Problem posting <select> multiple value Can't Post

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


Jason
Staff / Moderator


Dec 29, 2011, 11:41 AM

Post #2 of 3 (242 views)
Shortcut
Re: [dennisoneil] Problem posting <select> multiple value [In reply to] Can't Post

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:


Code
  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 - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


dennisoneil
User

Dec 29, 2011, 12:42 PM

Post #3 of 3 (240 views)
Shortcut
Re: [Jason] Problem posting <select> multiple value [In reply to] Can't Post

Worked perfectly. Thanks Jason.