儲存不到 utf8格式的資料

edited 十月 2013 in PHP新手區
各位大大,
本人是php初學者,現遇上一個解決不了的問題,請各位幫幫手~~
我利用php編寫輸入資料至oracle的網頁,在save過程中,有些中文字不見了,例如”埗”,查看後發覺big5中是沒有”埗”字,之後我把字轉為utf8,但save後,error出現如下 --
<b>Fatal error</b>: Call to a member function MoveFirst() on a non-object in <b>D:/xx.php</b>on line<119</b>

Code:
function GetElementContentAsstring($Obj_Element){
 $Obj_HolderDocument = new DOMDocument();
 $Obj_HolderDocument->loadXML('<holder></holder>');
 $Obj_DocumentElement = $Obj_HolderDocument->documentElement;
 $Obj_ImportedElement = $Obj_HolderDocument->importNode($Obj_Element, true);
 $Obj_DocumentElement->appendChild($Obj_ImportedElement);
 $Str_HolderNode = $Obj_HolderDocument->saveXML($Obj_ImportedElement);
 return $Str_HolderNode;
}

$xmlString = file_get_contents("php://input");
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($xmlString);
$xmlAttr = $xmlDoc->getElementsByTagName("attribute");

if ($xmlAttr){
$CAPTION=trim($ZONE_CAPTION_c);

if ($action == 'new'){
$sql="select count(*) from data where CAPTION = '".$CAPTION."';
$rs = $db->Execute($sql);
$rs->MoveFirst();
$arr = $rs->FetchRow();
$rec_count = $arr[0];
if ($rec_count > 0){
echo "Duplicate!";
exit();
}
$SQL="INSERT into data (CAPTION) ";
$SQL=$SQL."values(N'".$CAPTION."')";
$result=$db->Execute($SQL);
}
以上的php檔已save為utf8,如把caption轉為big5,error就會消失,但”埗”字不見了,如不轉為big5,error就會出現.
請問向位有何高見??

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=4373

評論

Sign In or Register to comment.