Hello,
I do not see $data defined, so what is it ?
function prepared_insert($conn, $table, $data) {
$keys = array_keys($data);
$keys = array_map('escape_mysql_identifier', $keys);
$fields = implode(",", $keys);
$table = escape_mysql_identifier($table);
$placeholders = str_repeat('?,', count($keys) - 1) . '?';
$sql = "INSERT INTO $table ($fields) VALUES ($placeholders)";
prepared_query($conn, $sql, array_values($data));
}
Code found in this tutorial:
https://phpdelusions.net/mysqli_examples/insert