[問題] 中文儲存資料庫發生錯誤

phpBB Installation & Usage Support
phpBB 2 安裝於各類型作業平台之問題討論;外掛問題,請到相關版面依發問格式發表!
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

版面規則
本區是討論關於 phpBB 2.0.X 架設安裝上的問題,只要有安裝任何外掛,請到外掛討論相關版面按照公告格式發表。
(發表文章請按照公告格式發表,違者砍文)
主題已鎖定
stevenkao
星球普通子民
星球普通子民
文章: 6
註冊時間: 2005-04-29 17:08

[問題] 中文儲存資料庫發生錯誤

文章 stevenkao »

我是用 PhpBB 2.0.14 MSSQL2000 PHP 4.3.11 Win2000

在發表文章中有出現某些中文會有錯誤發生 例如 "課程講義"
"軟體產品開發流程管理實務"

錯誤碼不一定,例如 存 "軟體產品開發流程管理實務"

代碼: 選擇全部

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver]COUNT 欄位不正確或語法錯誤, SQL state 07001 in SQLExecDirect in C:\phpBB2\db\mssql-odbc.php on line 117

Warning: Cannot modify header information - headers already sent by (output started at C:\phpBB2\db\mssql-odbc.php:117) in C:\phpBB2\includes\page_header.php on line 475

Warning: Cannot modify header information - headers already sent by (output started at C:\phpBB2\db\mssql-odbc.php:117) in C:\phpBB2\includes\page_header.php on line 477

Warning: Cannot modify header information - headers already sent by (output started at C:\phpBB2\db\mssql-odbc.php:117) in C:\phpBB2\includes\page_header.php on line 478

代碼: 選擇全部

一般錯誤 
  
Could not select words

DEBUG MODE

SQL Error : 07001 [Microsoft][ODBC SQL Server Driver]COUNT 欄位不正確或語法錯誤

SELECT word_id, word_text FROM phpbb_search_wordlist WHERE word_text IN ('軟體產?, '發流?, '管理實務')

Line : 172
File : functions_search.php 
 
存 "課程講義"

代碼: 選擇全部

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]行 3: '講義' 附近的語法不正確。, SQL state 37000 in SQLExecDirect in C:\phpBB2\db\mssql-odbc.php on line 117

Warning: Cannot modify header information - headers already sent by (output started at C:\phpBB2\db\mssql-odbc.php:117) in C:\phpBB2\includes\page_header.php on line 475

Warning: Cannot modify header information - headers already sent by (output started at C:\phpBB2\db\mssql-odbc.php:117) in C:\phpBB2\includes\page_header.php on line 477

Warning: Cannot modify header information - headers already sent by (output started at C:\phpBB2\db\mssql-odbc.php:117) in C:\phpBB2\includes\page_header.php on line 478

代碼: 選擇全部

Could not select words

DEBUG MODE

SQL Error : 37000 [Microsoft][ODBC SQL Server Driver][SQL Server]行 3: '講義' 附近的語法不正確。

SELECT word_id, word_text FROM phpbb_search_wordlist WHERE word_text IN ('課?, '講義')

Line : 172
File : functions_search.php
請問我該如何著手解決這個問題呢???
kp3011
竹貓忠實會員
竹貓忠實會員
文章: 384
註冊時間: 2004-05-15 21:16
來自: HKG

文章 kp3011 »

●架設主機作業系統:CentOS 4.7
●您的 phpBB2 版本:phpBB 3.0.4
●您的 domain(網域名稱):www.hkbf.org | forum.hkbrda.org
Mac
百戰天龍馬蓋先
百戰天龍馬蓋先
文章: 2590
註冊時間: 2003-02-02 02:28
來自: MacphpBBMOD
聯繫:

文章 Mac »

看來是編碼問題

代碼: 選擇全部

SQL Error : 37000 [Microsoft][ODBC SQL Server Driver][SQL Server]行 3: '講義' 附近的語法不正確。

SELECT word_id, word_text FROM phpbb_search_wordlist WHERE word_text IN ('課?, '講義') 
在繼續協助你之前,請先補上發問格式
大家也才好幫助你

~Mac
+ 關於 phpBB 使用問題請在版面發問,私人訊息提供其他不相干或是隱私的事情聯絡之用。

phpBB 官網 | 竹貓星球 | MacphpBBMOD | 我的服務
stevenkao
星球普通子民
星球普通子民
文章: 6
註冊時間: 2005-04-29 17:08

文章 stevenkao »

您好
補上發文格式

●架設主機作業系統:Windows 2000 professional
●快速架站程式:no
●您的上網方式:公司內部網路\r
●您安裝的程式:IIS + php + MSSQL 2000
●您的 phpBB2 版本:phpBB 2.0.14
●您的 domain(網域名稱) :在公司內部網路, internet無法連結
●您的 phpBB2 連結網址: 在公司內部網路, internet無法連結
●錯誤代碼:請參考原發文

●錯誤狀態:請參考原發文

\r
to kp3011
請問是資料表哪裡有問題需要修復呢?是否可在詳細說明
to Mac
編碼問題要如何解決呢???

謝謝大家的幫忙
Mac
百戰天龍馬蓋先
百戰天龍馬蓋先
文章: 2590
註冊時間: 2003-02-02 02:28
來自: MacphpBBMOD
聯繫:

文章 Mac »

IIS + MSSQL,說實在的,我也不清楚這兩樣對 BIG5 中文的支援度有多高 ^^"

~Mac
+ 關於 phpBB 使用問題請在版面發問,私人訊息提供其他不相干或是隱私的事情聯絡之用。

phpBB 官網 | 竹貓星球 | MacphpBBMOD | 我的服務
stevenkao
星球普通子民
星球普通子民
文章: 6
註冊時間: 2005-04-29 17:08

文章 stevenkao »

不知道我遇到的這個問題和下面這篇文章所提到的會不會有關係?
如果修正了多國語言能不能解決呢\r

[整理]多國語言修正
http://phpbb-tw.net/phpbb/viewtopic.php?t=18116
streitleak
星球公民
星球公民
文章: 261
註冊時間: 2003-07-26 04:44
來自: 龍潭
聯繫:

文章 streitleak »

To Mac
中文版的支援度沒問題,但是對BIG5的日文字就不知道了。

To stevenkao
單純的SQL語法問題,跟是不是多國語言修正無關。
注意一下跟語法有關的字串處理吧。
台灣動漫論壇
http://ACGFan.twbbs.org
星
汝命短眷族望聞
我望 
汝本將末看取
-------------《人類帝國國歌一節
~倉木麻衣~
竹貓忠實會員
竹貓忠實會員
文章: 1405
註冊時間: 2004-03-21 21:00

文章 ~倉木麻衣~ »

關鍵應該是function clean_words()裡的這段\r

代碼: 選擇全部

	static $drop_char_match =   array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\\', '/', '=', '#', '\'', ';', '!');
	static $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', '',  ' ',  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ',  ' ', ' ');

	for($i = 0; $i < count($drop_char_match); $i++)
	{
		$entry =  str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
	}
與使用的資料庫種類無關~
stevenkao
星球普通子民
星球普通子民
文章: 6
註冊時間: 2005-04-29 17:08

文章 stevenkao »

~倉木麻衣~ 寫:關鍵應該是function clean_words()裡的這段\r

代碼: 選擇全部

	static $drop_char_match =   array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\\', '/', '=', '#', '\'', ';', '!');
	static $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', '',  ' ',  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ',  ' ', ' ');

	for($i = 0; $i < count($drop_char_match); $i++)
	{
		$entry =  str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
	}
與使用的資料庫種類無關~
沒錯,我今天到公司查了一下,在functions_search.php中的function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)

$entry這個變數,一開始傳進來時給的值是"課程講義",我一直追蹤這個變數的值,直到如~倉木麻衣~兄所說,run到\r

代碼: 選擇全部

//
	// Filter out strange characters like ^, $, &, change "it's" to "its"
	//
	for($i = 0; $i < count($drop_char_match); $i++)
	{
		$entry =  str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
	}
這一段,"課程講義"就會被str_replace取代成"課?講義",因此導致存進資料庫時出錯,因此我在猜想應該是php對字串編碼的問題,不知道各位高手對這個問題,我是該如何去修改呢??
主題已鎖定

回到「phpBB 2 安裝與使用」