[WEB][PHP] 關於網站線上人數統計的實做

[WEB][PHP] 關於網站線上人數統計的實做

如果網頁是使用 PHP 來寫的話,可以很容易做到基本的網站人數統計功能。

1. 去改寫 session 的處理方式,例如以下是將原本存到 file 的 session 資料變成存到 MySql 之類的 (memory) database. (註一):

去用 session_set_save_handler() 函式改寫 session 在

  • open(),
  • close(),
  • read(),
  • write(),
  • destroy(),
  • Gc()

時的處理方式。

其中: Continue reading “[WEB][PHP] 關於網站線上人數統計的實做”

安裝 PHP 時出現error: Cannot find MySQL header files under yes的錯誤訊息

[服務架設][系統]安裝 PHP 時出現error: Cannot find MySQL header files under yes的錯誤訊息

安裝 PHP 時,剛執行 ./configure –with-apxs2=/usr/local/Apache2/bin/apxs –with-mysql
就出現以下錯誤訊息:

…..
checking for mSQL support… no
checking for MSSQL support via FreeTDS… no
checking for MySQL support… yes
checking for specified location of the MySQL UNIX socket… no
checking for MySQL UNIX socket location… /tmp/mysql.sock
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore.

解法:

o 如果不知道 header file 在哪,用 「find / -name mysql.h」命令找出其位置;
o 如果是自己也有手動安裝 MySQL 套件的話,直接指定該位置。

在 ./configure 下參數指定 header file 的位置,如下:

./configure –with-apxs2=/usr/local/Apache2/bin/apxs –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config

這篇文章的關鍵字:
PHP install (PHP安裝), MySQL header files

將MySQL升級成4.1版遇到 ‘Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in …..’ 錯誤訊息要如何解?

[服務架設][系統]將MySQL升級成4.1版遇到 ‘Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in …..’ 錯誤訊息要如何解?

錯誤發生的原因是 4.1 版以後的密碼採用新的密碼驗證機制,如果用 myPhpAdmin 去新增出來的使用者,會採用新的機制給予密碼,舊的 mysql client 連進來要驗證密碼時就會出現上述錯誤。

解法:

將該要給舊 mysql client 用的帳號改成舊有的密碼機制,例如用新的 mysql 做以下動作:

$ mysql -h new_server_host -u root -p
mysql> SET PASSWORD FOR ‘some_user‘@’some_host‘ = OLD_PASSWORD(‘new_password‘);
mysql> FLUSH PRIVILEGES;

紅色標示的部分依照自身情況給值。

詳情請看這裡

[LINUX]安裝 PHP 時出現undefined reference to `libiconv_open’ 之類的錯誤訊息

[服務架設][系統][LINUX]安裝 PHP 時出現undefined reference to `libiconv_open’ 之類的錯誤訊息

安裝環境: Linux Fedora Core 3 上安裝 php-5.2.0

在安裝 PHP 到系統中時要是發生「undefined reference to `libiconv_open’」之類的錯誤訊息,那表示在「./configure 」沒抓好一些環境變數值。錯誤發生點在建立「-o sapi/cli/php」時出錯,沒給到要 link 的 iconv 函式庫參數。

快速的解法是: Continue reading “[LINUX]安裝 PHP 時出現undefined reference to `libiconv_open’ 之類的錯誤訊息”

[HTML][JS] 為 textarea 增加 maxlength 屬性

[HTML][JS] 為 textarea 增加 maxlength 屬性

o 如果只是單純地想限制 textarea 中的字數,不想寫太多的話,可用:

[cc lang=”javascript” width=”100%”][/cc]

[cc lang=”javascript” width=”100%”][/cc]

o 在 textarea 的 onkeyup 中檢查字數之方法:

Continue reading “[HTML][JS] 為 textarea 增加 maxlength 屬性”

postfix 中只開 localhost 網路介面或跑 Virtual Host 時, 碰到 loops back to myself 錯誤要如何解決?

[服務架設][系統] postfix 中只開 localhost 網路介面或跑 Virtual Host 時, 碰到 loops back to myself 錯誤要如何解決?

在某些需求下,系統管理者可能只想跑起 postfix mail server (SMTP server) 去服務 localhost 網路介面來的要求,以幫本機系統上的一些服務代送信件(Relay Mail) (註一);又或著在跑 Virtual Host 時,當碰到『loops back to myself』錯誤訊息要如何解決?請看以下說明。 Continue reading “postfix 中只開 localhost 網路介面或跑 Virtual Host 時, 碰到 loops back to myself 錯誤要如何解決?”

[SEO][架站] 使用 Apache 的 ReWrite 設定讓 URL 變短(short URL)、變成靜態樣式

使用 Apache web server 的ReWrite 設定,很方便地可將原本是『postshow.php?PoId=178』樣式的動態產生頁面,變成『postshow_178.html』形式的 ‘靜態頁面’。

使用 ReWrite 的好處一方面可以讓 URL 看起來比較短,不帶參數的 ‘靜態頁面’ 形式對使用者來說比較習慣;另一方面是,一般認為有利於 SEO,搜尋引擎比較好抓。

在這僅舉個簡單例子:『postshow.php?PoId=178』樣式改成『postshow_178.html』形式的 ‘靜態頁面’。 Continue reading “[SEO][架站] 使用 Apache 的 ReWrite 設定讓 URL 變短(short URL)、變成靜態樣式”

[WEB][PHP][SEO] 轉導、轉向(Redirect)網址的方法.

[WEB][PHP][SEO] 轉導、轉向(Redirect)網址的方法

在將網站更換成新網址的情況下,可能會在舊網址上使用到一些『轉導網址』的方法,以便將原本的使用者及其流量引導到新的網址去。

以下整理、討論到幾種轉導(Redirect)網址的技術方法,並且探討該方法對 SEO 的影響: Continue reading “[WEB][PHP][SEO] 轉導、轉向(Redirect)網址的方法.”