trying to create one plugin, getting some issue to submit the array data in wordpress database.
$formDATA gets the array value now issue is when
$sql = "INSERT INTO `".$table_name ."` (`paid_arr`) VALUES '".$formDATA."'";
$result = $wpdb->insert($table_name,$formDATA);
getting strange warnings and errors not able to insert data in wp DB.
Warning: array_keys() expects parameter 1 to be array, string given in /home3/mahesh/public_html/project/lal/wp-includes/wp-db.php on line 1316
Warning: Invalid argument supplied for foreach() in /home3/mahesh/public_html/project/lal/wp-includes/wp-db.php on line 1318
Warning: implode() [function.implode]: Invalid arguments passed in /home3/mahesh/public_html/project/lal/wp-includes/wp-db.php on line 1327
here is php code;
$formDATA = array(
'fname' => $fname,
'lname' => $lname,
'email' => $paidemail,
'Phone' => $paidphone,
'gender' => $gender,
'hobbies' => $interest,
'hear' => $city,
'message' => $message_field,
'time' => $curtime
);
formsubmitpaid($formDATA);
function formsubmitpaid( $formDATA ) {
global $wpdb;
$formDATA = json_encode($formDATA);
$table_name = $wpdb->prefix . "padi_forms";
$sql = "INSERT INTO `".$table_name ."` (`paid_arr`) VALUES '".$formDATA."'";
$result = $wpdb->insert($table_name,$formDATA);
if( !$result ){
echo '<script>alert("dfdf")</script>';
} else {
echo '<script>alert("No")</script>';
}
print_r($sql);
print_r($result);
}