When I send data to wpdb from form I can have some empty fields. How can I add conditions to array of data inside array or before insert wpdb to send only filled fields ?
The fields concerned (for example $serializedpaisol has no value(empty)) have already be checked to know if values exist, but the wpdb->insert find always this data name but is empty:
if(isset($paisol)){
$serializedpaisol = maybe_serialize($paisol);
}
$data = array(
'name' => $_POST['aacl_title'],
'nicname' => $Acronyme,
'img' => $idImage,
'info' => $_POST['aac_description'],
'resume' => $_POST['aac_resume'],
'statut' => $serializedcp,
'mgmt_act' => 1,
'website' => $serializedurllink,
'payment_solutions' => $serializedpaisol,
'mail'=> $mail,
'tel'=> $tel,
'location'=> $serializedloc,
'date'=> $timeday
);
$format = array('%d','%s','%s','%d','%s','%s','%s','%d','%s','%s','%s','%s','%s','%s');
$table = $wpdb->prefix.'table_data';
$wpdb->insert($table,$data,$format);
When I send form I get "Notice: Undefined variable: serializedpaisol"
I don't understand well wpdb::prepare , does it check the existence of data value before to send to database ?