1 頁 (共 1 頁)

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

發表於 : 2005-04-29 17:38
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
請問我該如何著手解決這個問題呢???

發表於 : 2005-04-30 22:04
kp3011

發表於 : 2005-04-30 23:09
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

發表於 : 2005-05-01 10:00
stevenkao
您好
補上發文格式

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

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

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

謝謝大家的幫忙

發表於 : 2005-05-01 12:21
Mac
IIS + MSSQL,說實在的,我也不清楚這兩樣對 BIG5 中文的支援度有多高 ^^"

~Mac

發表於 : 2005-05-01 14:24
stevenkao
不知道我遇到的這個問題和下面這篇文章所提到的會不會有關係?
如果修正了多國語言能不能解決呢\r

[整理]多國語言修正
http://phpbb-tw.net/phpbb/viewtopic.php?t=18116

發表於 : 2005-05-01 23:31
streitleak
To Mac
中文版的支援度沒問題,但是對BIG5的日文字就不知道了。

To stevenkao
單純的SQL語法問題,跟是不是多國語言修正無關。
注意一下跟語法有關的字串處理吧。

發表於 : 2005-05-02 01:09
~倉木麻衣~
關鍵應該是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);
	}
與使用的資料庫種類無關~

發表於 : 2005-05-03 10:11
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對字串編碼的問題,不知道各位高手對這個問題,我是該如何去修改呢??