I'm trying to loop a insert query, however i keep getting an error, which seem to be related to my close() statements?
i have following code which keep returning following error:
Fatal error: Call to a member function close() on a non-object in
i've on purpose removed the information $variables in the insert_news query, inorder to simplify the question
function check_text($text, $last_id) {
global $ids;
foreach($ids as $id => $teams) {
foreach($teams as $team) {
if(stripos(($text, $team) !== false) {
$teamRelation = $con->prepare("INSERT INTO contain (`team_id`, `news_id`) VALUES (?, ?)");
$teamRelation->bind_param("ii", $id, $last_id);
$teamRelation->execute();
}
}
}
$teamRelation->close();
}
function scrape_afton() {
foreach($afton->find("//section/ul/li") as $afton_element) {
$insert_news = $con->prepare("INSERT INTO news (`title`, `url`, `image_url`, `date`, `news_text`, `website_id`) VALUES (?, ?, ?, ?, ?, 1)");
$insert_news->bind_param("sssss", $afton_title, $afton_link, $afton_img, $afton_datetime, $full_text_dont);
$insert_news->execute();
$afton_last_id = $con->insert_id;
check_text($afton_full_text, $afton_last_id);
}
}