|
|
|
รบกวนพี่ช่วยแก้ปัญหา public_html/news/submit.php on line 14 นี้หน่อยครับ |
|
|
|
|
|
|
|
Code
Fatal error: Call to a member function getAttribute() on a non-object in /home/xxxxx/public_html/news/submit.php on line 14
คือผมทำระบบดึงข่าวอะครับแต่มันขึ้นงี้ ทำไงดี Error บรรทัดที่ 14
โค้ดนี้เป็นโค้ดส่วน submit.php โดยระบบนี้ผมจะส่งเข้าฐานข้อมูลของ wordpress ที่ผมใช้อยู่ครับ... แก้ปัญหานี้ไม่ได้สักที มันเกี่ยวกับอะไรครับ
Code (PHP)
<?php
if($submitnew==1){
$filename = $xml;
$dom = new DOMDocument();
if ($dom->load($filename)) {
$data = $dom->getElementsByTagName("item");
foreach($data as $theData) {
$title = trim($theData->getElementsByTagName("title")->item(0)->nodeValue);
$description = trim($theData->getElementsByTagName("description")->item(0)->nodeValue);
$link = trim($theData->getElementsByTagName("link")->item(0)->nodeValue);
$image = trim($theData->getElementsByTagName("enclosure")->item(0)->getAttribute('url'));
$i=0;
$strSQL = "SELECT * FROM ".$fix."posts WHERE post_content_filtered = '$link'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery)) {
$i=++$i;
}
if($i==0){
$contentdata=file_get_contents("$link");
$next_start=0;
$start=strpos($contentdata,'<div id="details" class="page">',$next_start);
if($next_start==0){
$end = strpos($contentdata,'</p></p>',$start);
$content = substr($contentdata,$start,($end-$start));
$next_start=1;
}
$pos1 = explode("<img src=\"",$content);
$content = implode("<img src=\"http://www.innnews.co.th",$pos1);
$pos1 = explode("th /images/",$content);
$content = implode("th/images/",$pos1);
$pos1 = explode("<div class=\"column-420 column-left\">",$content);
$content = implode("",$pos1);
$pos1 = explode("<div class=\"det-news-detail\">",$content);
$content = implode("",$pos1);
$pos1 = explode("<div id=\"details\" class=\"page\">",$content);
$content = implode("",$pos1);
$pos1 = explode(" alt=\"\" class=\"detail-image\" />",$content);
$content = implode("",$pos1);
$content = "$content</p></p>";
//echo '<a href="'.$link.'">'.$title."</a><br />";
//echo $content;
$date = date("Y-m-d");
$time = date("H:i:s");
$alias = date("Y-m-d-H-i-s");
$ip = $_SERVER["REMOTE_ADDR"];
$pos1 = explode("'", $title);
$title = implode("\'",$pos1);
$pos2 = explode("'", $content);
$content = implode("\'",$pos2);
$copy = "<br> เนื้อหาจาก<a href=\"$link\" target =\"_blank\">innnews</a>";
$content ="$content $copy";
$strSQL3 = "INSERT INTO ".$fix."posts
VALUES ('', '$wp_userid', '$date $time', '$date $time', '$content', '$title','', 'publish', 'open', 'open',
'', '', '','','$date $time','$date $time','$link','0',
'','0','post','','0')";
$objQuery3 = mysql_query($strSQL3) or die ("Error Query [".$strSQL3."]");
$strSQL = "SELECT * FROM ".$fix."posts WHERE post_content_filtered = '$link'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery)) {
$PostID =$objResult["ID"];
}
$strSQL33 = "INSERT INTO ".$fix."term_relationships
VALUES ('$PostID', '$wp_categoriesID', '0')";
$objQuery33 = mysql_query($strSQL33) or die ("Error Query [".$strSQL33."]");
$strSQL5= "UPDATE ".$fix."term_taxonomy SET count = count+1
WHERE term_id = '$wp_categoriesID'";
$objQuery5 = mysql_query($strSQL5) or die ("Error Query [".$strSQL5."]");
}
}
} else {
echo("This document is not valid!");
}
}
?>
Tag : PHP
|
|
|
|
|
|
Date :
2012-10-04 19:00:09 |
By :
เนส |
View :
1025 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าเคยใช้ได้แสดงว่า getAttribute() น่าจะเป้นที่ Version ของ PHP ครับ
|
|
|
|
|
Date :
2012-10-05 10:42:02 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|