Answer the question
In order to leave comments, you need to log in
Why is it not looking for news in the database by title?
Good afternoon. I take news from the regional site:
$html = file_get_contents('https://my-domain.ru');
$doc = phpQuery::newDocument($html);
$news = array();
$entry = pq("article")->find(".lenta-big-item");
foreach($entry as $row ){
$row = pq($row);
$title = $row->find('.lenta-title')->text();
$i = search_news(trim($title));
if( $i ){
$news[] = $row->find('.lenta-title')->attr('href');
}
}
function search_news( $title = '' ){
include "../includes/config.php";
$query = "SELECT * FROM news WHERE news_title LIKE '%$title%'";
$r = mysqli_query($connect, $query);
if($r->num_rows == 0) {
return true;
}else{
return false;
}
mysqli_close($connect);
}
Answer the question
In order to leave comments, you need to log in
https://habr.com/en/post/563530/ As galaxy
correctly wrote in the comments, if the database "does not find" something, you need to convert both strings to a binary representation using bin2hex() and see the difference.
and then add str_replace based on the results
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question