$key = "id,name";
$val = "'$lastid','$autor'";
...
if ($email){
$key .= ",email";
$val .= ",'$email'";
}
...
$keys = \explode(',', $key);
$vals = \explode(',', $val);
$arr = array_combine($keys,array_fill(0,count($keys),$vals));
....
//O array montado fica assim:
// INSERT INTO autores (id, name, email) VALUES (:id, :name, :email)
$insok = $pdo->insert($arr);
if (!$insok) {
$error = "Erro ao inserir dados<br>".print_r($conn->errorInfo());
}
echo $error; // mostra o seguinte resultado
//array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL }
I would like to know how to resolve this error: