2010年11月3日 星期三

MYSQL編碼

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER_SET_CLIENT=utf8");
mysql_query("SET CHARACTER_SET_RESULTS=utf8");

2010年8月22日 星期日

android findViewById()

findViewById() 這個函式

"Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle)."

也就是只能抓到一開始在onCreate(Bundle)函式中設定的 xml layout

EditText str1=(EditText)textEntryView.findViewById(R.id.username_edit);
EditText str2=(EditText)textEntryView.findViewById(R.id.password_edit); 
String m_username=str1.getText().toString(); 
String m_password=str2.getText().toString();

Java == 與 equal

1.= =

測試物件參考時,唯有當兩個參考指向同一物件時,==運算子的結果才為true,同樣的,唯有當兩個參考指向不同物件時,!=運算子的結果才為true,這兩個運算子的處理與物件的內容無關。需要特別注意的是,在String中使用==,因為Java為節省記憶體,會在某一輪調區中維護唯一的String物件,所以如果在類別裡使用同一字串,Java只會建立一個唯一的字串而已。

2.equals

另一種測試的做法是equalsequals在類別為Java原先就存在時,是比較兩個物件是否為相同類型的類別後再比較其內容值是否相同,是就傳回true,否就傳回false。當要測試的類別是自定類別時,要依自定類別所提供的equals來決定如何比較,如果自定類別沒有覆蓋Objectequals類別的話,就以Objectequals來比較,Objectequals的比較方式如同 = =

2010年3月26日 星期五

mysqladmin: connect to server at 'localhost' failed

Setp 1. service mysql stop

Step 2.mysqld_safe --skip-grant-tables &

Step 3. mysql -u root mysql

Step 4. UPDATE user SET Password=PASSWORD('new password') where USER='root';

Step 5. FLUSH PRIVILEGES;

Step 6. quit

2010年1月13日 星期三

Drupal 6 問題解決之道

Q1 :安裝過程出現錯誤 "Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/drupal-6.15/includes/file.inc on line 902"

A1:修改 file.inc檔案,在902行增加mb_
vi /opt/lam/htdocs/drupal-6.15/include/file.inc
elseif ($depth >= $min_depth && mb_ereg($mask, $file)) {

2010年1月7日 星期四

CentOS 5 VNC Server

Step1. 確認是否有安裝 VNC Server 套件

#rpm -q vnc vnc-server
vnc-server-4.1.2-9.el5

Step2. 修改 vnc server 設定檔

#vi /etc/sysconfig/vncservers
VNCSERVERS="1:root" //
VNCSERVERARGS[1]="-geometry 1024x768"

Step3. 設定VNC密碼

#vncpasswd

Password: //輸入 VNC 密碼
Verify: //再輸入一次 VNC 密碼以確認

Step4. 修改 ~/.vnc/xstartup

#vi ~/.vnc/xstartup
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER //將此行 mark 拿掉
exec /etc/X11/xinit/xinitrc //將此行 mark 拿

Step5. 啟用VNC Server

#service vncserver start