일부 구문 분석 된 데이터를 mysql 데이터베이스에 저장하려고한다. 나는이 질문은 이미 여러 번 요청 알고간단한 HTML DOM Parser를 사용하여 원격 HTML 파일을 구문 분석 할 때받은 값이 mysql 데이터베이스에 저장되지 않음
Warning: mysqli_query() expects parameter 1 to be mysqli, string given
: 나는 아무것도 발생하지 않았다, mysql_query
를 사용하여 때
<?php
include('mysql_connection.php');
include('simplehtmldom_1_5/simple_html_dom.php');
$site = "www.xyz.com/19326072316";
$html = file_get_html($site);
foreach($html->find('body') as $body)
{
foreach($body->find('a.url') as $e)
{
$title = $e->plaintext;
echo '<b>Title: </b>' . $title . '<br>';
}
foreach($body->find('a.category') as $cat)
{
$category = $cat->plaintext;
echo '<b>Category: </b>' . $category . '<br>';
}
preg_match('/(\w+)\.xyz\.com\/.+/', $site, $matches);
$city = $matches[1];
echo '<b>City: </b>' . $matches[1] . '<br>';
foreach($body->find('div.month') as $month){
$month = $month->plaintext;
echo '<b>Start and end month: </b>' . $month . '<br>';
}
foreach($body->find('div.date') as $date){
$date = $date->plaintext;
preg_match('/([0-9]{1,2})/', $date, $match_date);
$date = $match_date[0];
echo '<b>Start and end date: </b>' . $date . '<br>';
}
foreach($body->find('li.new_WatchIcon') as $time){
$time = $time->plaintext;
echo '<b>Time: </b>' . $time . '<br>';
}
foreach($body->find('li#new_locationIconIE7 div') as $address){
$address = $address->plaintext;
echo '<b>Address: </b>' . $address . '<br>';
}
foreach($body->find('span.description') as $description){
$description = $description->innertext;
echo '<b>description: </b>' . $description . '<br>';
}
$query = ("INSERT INTO articles (event_name, date_added, start_date, start_month, end_date, end_month, year, city, state, full_address, time, description, contact) VALUES('$title', now(), '$date', '$month', '$date', '$month', '2014', '$city', 'Karnatka', '$address', '$time', '$description', 'NULL')") or die(mysql_error());
$run_query = mysqli_query($query, $connection);
}
?>
하지만 다음 mysqli_query
을 사용할 때 나는 다음과 같은 오류가 발생했습니다 : 내 코드는 아래와 같습니다 하지만이 문제를 해결하기위한 대부분의 방법을 시도했지만 나에게는 아무런 효과가 없었습니다!
mysqli_query에 대한 호출 결과를 확인하지 않습니다. 또한 mysql_query와 mysqli_query는 서로 관련이 없다는 점에 유의하십시오. 교환 할 수 없습니다. –