|
 |
|
ช่วยทีครับเวลารันแล้วมันขึ้น Error Query [INSERT INTO wp_posts VALUES ('', '1', '2012-11-02 20:10:22', '2012-11-02 20:10:22', ' |
|
 |
|
|
 |
 |
|
ผมลองรันแล้วมันขึ้นงี้อะครับ... Error Query [INSERT INTO wp_posts VALUES ('', '1', '2012-11-02 20:03:57', '2012-11-02 20:03:57', '
ช่วยตรวจดูให้ผมทีว่าผมทำตรงไหนผิดไป ลองบน hosting cPanel X แล้วปกติ พอมาลองอัพขึ้นโฮส ที่ใช้ DirectAdmin ไม่ได้ซะงั้น...
ลองรันดูแล้วมันขึ้นงี้....
Code
http://seesai.com/wp/run.php
submit.php
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.thairath.co.th",$pos1);
$pos1 = explode("th /media/",$content);
$content = implode("th/media/",$pos1);
$pos1 = explode("<div class=\"column-420 column-left\">",$content);
$content = implode("",$pos1);
$pos1 = explode("<div class=\"entry\">",$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\">หนังสือพิมพ์ไทยรัฐ</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, MySQL

|
|
 |
 |
 |
 |
Date :
2012-11-02 20:12:27 |
By :
sorawit.ff |
View :
944 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สงสัยหลับกันหมดแล้วแน่เลย  
|
 |
 |
 |
 |
Date :
2012-11-02 21:30:37 |
By :
sorawit.ff |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันไม่เกี่ยวกับ control panel หรอก มันเกี่ยวกับ my.ini ที่ hosting ตั้งไว้
เวลา insert แบบมี key เป็น autoincrement หลายคนเขียนแบบข้างบนแล้วได้ แล้วคิดว่าเป็นวิธีเขียนที่ถูก syntax แล้ว ไม่ใช่นะครับ
ควรระบุ field และ value จะได้รันที่ไหนก็ได้นะครับ
insert into table (field1, field2) values (value1, value2)
|
 |
 |
 |
 |
Date :
2012-11-03 09:25:35 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วผมจะระบบ field และ value ยังไครับ
ผมไม่รู้จริงๆ... โค้ดนี้เอามาต่อจากคนอื่นช่วยแนะนำหน่อยครับ
|
 |
 |
 |
 |
Date :
2012-11-03 17:56:13 |
By :
sorawit.ff |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|