php - Wordpress: checkboxes in plugin -


i have code...

    $wpdb->update(          $table_name_employee,          array(              'id' => $_post["user"],              'role' => $_post["role"],              'seniority' => $_post["seniority"],              'payroll' => $_post["payroll"],              'reportto' => $_post["reportto"],              'tasks' => $_post["tasks"],          ),          array(              'id' => $_post["user"],          )      ); 

the value of $_post["tasks"] array , not string. derived checkbox code...

... <input type=checkbox name="tasks[]" value="38"> task 38 <input type=checkbox name="tasks[]" value="39"> task 39 <input type=checkbox name="tasks[]" value="40"> task 40 ... many more 

if change tasks[] task check value of 1 checkbox. if leave tasks[] value passed array $wpdb->update() command above fails error:

warning: mb_check_encoding() expects parameter 1 string, array given in /home/gj/public_html/matrix/bg/wp-includes/wp-db.php on line 2378  warning: mysql_real_escape_string() expects parameter 1 string, array given in /home/gj/public_html/matrix/bg/wp-includes/wp-db.php on line 1094 

my question is: how correctly modify $wpdb->update() above considering $_post["tasks"] array? searches have made have been unsuccessful in showing similar scenario.

vincent decaux pointed out brain fart , adding code before $wpdb->update() did trick...

    if (isset($_post['tasks']))     {         $_post['tasks']=implode("|", $_post['tasks']);     } 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -