|  | 
	                
  
    | 
	 
        ปัญหาแปลกๆเกี่ยวกับการ insert into ใน mysql ครับ เป็นเฉพาะตอนที่อัพขึ้นโฮสแล้ว     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | code? 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 01:27:57 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมใช้ระบบดึงข่าวน่ะครับ 
 Code
 
 <?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'));
			$pos1 = explode("http://www.thairath.co.th/content/",$link);
			$links = implode("",$pos1);
			$i=0;
			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("alt=\"\" class=\"detail-image\" />",$content);
					$content = implode("",$pos1);
					$pos1 = explode("<div id=\"details\" class=\"page\">",$content);
					$content = implode("",$pos1);
					$pos1 = explode("</div>",$content);
					$content = implode("",$pos1);
					$content = "$content</p></p>";
					//echo '<a href="'.$link.'">'.$title."</a><br />";
					//echo $content;     
				$date	= date("Y-m-d");
				$time	= time();
				$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><strong>ขอขอบคุณเนื้อหาข่าว คุณภาพดี โดย: <A HREF=\"$link\" target =\"_blank\">หนังสือพิมพ์ไทยรัฐ</A><BR>ต้นฉบับสคริปต์โดย <A HREF=\"http://www.educationboard.in.th/read.php?tid=91\" target =\"_blank\">Educationboard.in.th</A><BR>พัฒนาสคริปต์โดย : <A HREF=\"http://www.chowchil.com\" target =\"_blank\">Joneburapa</a></strong><BR>";
				$content ="$content $copy";
				$strSQL3 = "INSERT INTO cdb_threads (fid, readperm, price, iconid, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, status)
							VALUES ('$joomla_categoriesID', '0', '0', '0', '0', '0','$joomla_username', '$joomla_ID', '$title', 
							'$time', '$time', '$joomla_username', '0', '0', '0', '0', '0', '0')";
				$objQuery3 = mysql_query($strSQL3) or die ("Error Query [".$strSQL3."]");					
				$strSQLUser = "SELECT tid FROM `cdb_threads`";
				$objQueryUser = mysql_query($strSQLUser) or die ("Error Query [".$strSQLUser."]");
				while($objResultUser = mysql_fetch_array($objQueryUser)) {
					$tid		=$objResultUser["tid"];
				}		
				$strSQL33 = "insert into ".$fix."posts (`fid`, `tid`, `first`, `author`, `authorid`, `subject`, `dateline`, `message`, `useip`, `invisible`, `anonymous`, `usesig`, `htmlon`, `bbcodeoff`, `smileyoff`, `parseurloff`, `attachment`, `rate`, `ratetimes`, `status`) VALUES 
							            ('$joomla_categoriesID', '$tid', '1', '$joomla_username', '$joomla_ID', '$title', '$time', '$content', '$ip', '0', '0', '1', '1', '-1','-1', '0', '0', '0', '0', '0')";						
				$objQuery33 = mysql_query($strSQL33) or die ("Error Query [".$strSQL33."]");	
				
				$strSQL11 = "UPDATE ".$fix."forums SET  posts = posts+1
								 WHERE fid 	= '$joomla_categoriesID'";
				$strSQL11 = mysql_query($strSQL11) or die ("Error Query [".$strSQL11."]");
				$strSQL12 = "UPDATE ".$fix."forums SET  threads = threads+1
								 WHERE fid 	= '$joomla_categoriesID'";
				$strSQL12 = mysql_query($strSQL12) or die ("Error Query [".$strSQL12."]");		
				$strSQL13 = "UPDATE ".$fix."forums SET  todayposts = todayposts+1
								 WHERE fid 	= '$joomla_categoriesID'";
				$strSQL13 = mysql_query($strSQL13) or die ("Error Query [".$strSQL13."]");
				$strSQL14 = "UPDATE ".$fix."members SET posts = posts+1
								 WHERE username 	= '$joomla_username'";
				$strSQL14 = mysql_query($strSQL14) or die ("Error Query [".$strSQL14."]");
				$strSQL100 = "SELECT * FROM ".$fix."forums WHERE fid  = '$joomla_categoriesID'";
				$strSQL100 = mysql_query($strSQL100) or die ("Error Query [".$strSQL100."]");
				while($strSQL100 = mysql_fetch_array($strSQL100)) {
					$fup		=$strSQL100["fup"];
					$ifsub		=$strSQL100["ifsub"];
				}	
				
				if($ifsub==1){
				$strSQL11 = "UPDATE ".$fix."forums SET  posts = posts+1
								 WHERE fid 	= '$fup'";
				$strSQL11 = mysql_query($strSQL11) or die ("Error Query [".$strSQL11."]");
				$strSQL12 = "UPDATE ".$fix."forums SET  threads = threads+1
								 WHERE fid 	= '$fup'";
				$strSQL12 = mysql_query($strSQL12) or die ("Error Query [".$strSQL12."]");	
				$strSQL13 = "UPDATE ".$fix."forums SET  todayposts = todayposts+1
								 WHERE fid 	= '$fup'";
				$strSQL13 = mysql_query($strSQL13) or die ("Error Query [".$strSQL13."]");
				}
									
			}
		}
	} else {
		echo("This document is not valid!");
	}
}
?>
 แต่ว่าโค้ดเดียวกันกับที่ใช้ localhost ซึ่งพออัพไปแล้ว มันกลับ insert ไม่ได้น่ะครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 01:32:19 | By :
                            fox |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | error ตรงไหน เปลี่ยนนี่ให้หมดละกันจะได้เห็น error 
 or die ("Error Query
 เปลี่ยนเป็น
 or die (mysql_error() . "<br/>Error Query
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 01:59:27 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองแล้วมันขึั้นว่า 
  Quote: mysql_error() .Error Query [INSERT INTO threads ('fid', 'iconid', 'typeid', 'sortid', 'readperm', 'price', 'author', 'authorid', 'subject', 'dateline', 'lastpost', 'lastposter', 'views', 'replies', 'displayorder', 'highlight', 'digest', 'rate', 'special', 'attachment', 'moderated', 'closed', 'itemid', 'supe_pushstatus', 'recommends', 'recommend_add', 'recommend_sub', 'heats', 'status') VALUES ('2', '0', '0', '0', '0', '0','Robot', '625', 'หนุนผู้ประกอบการเรือ เร่งกู้เงินซื้อเรือใหญ่', '1305486782', '1305486782', 'Robot', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')]
ครับ
 
 
 จุดที่เออร์เรอร์คือตรงนี้ครับ
 
  Quote: $strSQL33 = "insert into ".$fix."posts (`fid`, `tid`, `first`, `author`, `authorid`, `subject`, `dateline`, `message`, `useip`, `invisible`, `anonymous`, `usesig`, `htmlon`, `bbcodeoff`, `smileyoff`, `parseurloff`, `attachment`, `rate`, `ratetimes`, `status`) VALUES ('$joomla_categoriesID', '$tid', '1', '$joomla_username', '$joomla_ID', '$title', '$time', '$content', '$ip', '0', '0', '1', '1', '-1','-1', '0', '0', '0', '0', '0')";
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 02:09:27 | By :
                            fox |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | $objQuery3 = mysql_query($strSQL3) or die (mysql_error() . "<br/>Error Query [".$strSQL3."]"); 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 02:29:21 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | มันขึ้นว่า 
  Quote: No database selectedError Query [INSERT INTO cdb_threads ('fid', 'iconid', 'typeid', 'sortid', 'readperm', 'price', 'author', 'authorid', 'subject', 'dateline', 'lastpost', 'lastposter', 'views', 'replies', 'displayorder', 'highlight', 'digest', 'rate', 'special', 'attachment', 'moderated', 'closed', 'itemid', 'supe_pushstatus', 'recommends', 'recommend_add', 'recommend_sub', 'heats', 'status') VALUES ('2', '0', '0', '0', '0', '0','Robot', '625', 'หนุนผู้ประกอบการเรือ เร่งกู้เงินซื้อเรือใหญ่', '1305488132', '1305488132', 'Robot', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')]
อ่ะครับ
 
 ไม่ได้เลือกฐานข้อมูล O.O
 
 ไหงเป็นงี้ T^T
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 02:31:56 | By :
                            fox |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ยังไม่มีการ connect database แล้วก็ select database ครับ สังเกตุว่าไม่เห็นการ include ไฟล์ที่เกียวข้องกับการ connect mysql เลย 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 02:45:52 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code 
 'fid', 'iconid', 'typeid', 'sortid', 'readperm', 'price', 'author', 'authorid', 'subject', 'dateline', 'lastpost', 'lastposter', 'views', 'replies', 'displayorder', 'highlight', 'digest', 'rate', 'special', 'attachment', 'moderated', 'closed', 'itemid', 'supe_pushstatus', 'recommends', 'recommend_add', 'recommend_sub', 'heats', 'status' 
 พวกนี้เอา ' ออกให้หมดครับ หรือใช้ ` ตรงตัวหนอน
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 03:06:26 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ได้แล้วครับ ขอบคุณมากๆครับ  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-05-16 15:37:05 | By :
                            fox |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |