I do this multi_query and get an error:
$date = date('Y-m-d H:i:s');
$searchLimit = $_POST['limitSearch'];
$inputDate = $_POST['dateSearch'];
$searchDate = date("Y-m-d H:i:s", strtotime($inputDate));
$topic = $_POST['topicSearch'];
foreach($_POST['check_list_search'] as $selected){
$journal = $selected;
$sql = "SELECT tbl.* FROM (SELECT date, section, title, teaser, href, image FROM scrap WHERE (date > '$searchDate' AND journal = '$journal' AND (LOWER(teaser)LIKE LOWER('%{$topic}%') OR LOWER(title) LIKE LOWER('%{$topic}%'))) ORDER BY date DESC LIMIT $searchLimit) as tbl GROUP BY tbl.title";
$sql .= "INSERT INTO search_loggedin (date, journal, inputdate, searchlimit, topic) VALUES ('$date', '$journal', '$searchDate', '$searchLimit', '$topic')";
$dbc->multi_query($sql);
$res = $dbc->store_result();
echo $dbc->error;
Undeclared variable: search_loggedin
I just created the table search_loggedin but I did the exact same query on another older table and it worked.
Why do I have this error?