發表文章

[MySQL] Table dbname/tablename is marked as crashed and should be repaired when using LOCK TABLES

來源 :  http://emn178.pixnet.net/blog/post/95064604-%E8%A7%A3%E6%B1%BAtable-'.-dbname-tablename'-is-marked-as-crashed-and-sh 當遇到 Table './dbname/tablename' is marked as crashed and should be repaired when using LOCK TABLES 原因: 資料表的相關檔案由於不明原因發生損壞,而無法正常存取。 解決方案: 可以使用以下兩種方式嘗試修復資料表: 使用SQL語句 REPAIR TABLE tablename 使用myisamchk 使用命令列進入資料表所在目錄,例如 cd /var/lib/mysql/dbname 執行 myisamchk -r tablename 執行過程中可能會遇到以下錯誤 myisamchk: error: myisam_sort_buffer_size is too small 這是修復過程中所需記憶體空間超過預設的空間,可以利用--sort_buffer_size參數指派更大的記憶體,例如: myisamchk -r tablename --sort_buffer_size=2G

[jQuery] append option to select

source :  http://stackoverflow.com/questions/170986/what-is-the-best-way-to-add-options-to-a-select-from-an-array-with-jquery $("#select_id").append($("<option></option>").attr("value","option_value").text("text_value")); 清除select中所有value !=0的option $ ( '#select_id option[value!="0"]' ). remove (); 雖然網路上都有,不過還是筆記一下比較方便囉

[jQuery] double click - dblclick()

想做的功能為對<table>內的<td>中的文字做出編輯的功能 為了方便,藉由點擊2下來觸發dblclick()來去處理

[PHP] CSV 強迫轉字串

來源 :  http://superuser.com/questions/318420/formatting-a-comma-delimited-csv-to-force-excel-to-interpret-value-as-a-string "= ""Data Here"" " 這樣就可以強迫把欄位全部都轉成字串囉

[PHP] PHP處理CSV

最近處理匯入CSV時才發現有個更方便的函式 fgetcsv 以前都是單純用  fgets  一行一行處理,但有同事給我csv資料中有欄位有包含\r\n.. 造成用  fgets  會整個大爆炸,所以才意外發現這個 ! 但讀取檔案時發現中文會部分消失,仔細google後才發現原來跟本地設定有關 所以只要再加入一行 setlocale(LC_ALL, "zh_TW.UTF-8"); 就可以解決了 ! 範例: setlocale(LC_ALL, "zh_TW.UTF-8"); $filePath = '/var/www/html/aaa.csv'; $file = fopen($filePath , "r"); while (!feof($file)) { $data = fgetcsv($file); // data為array }

[PHP] 讀檔編碼問題

mb_convert_encoding string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding = mb_internal_encoding() ] ) $str,要轉換編碼文字 $to_encoding ,要轉成的編碼,如utf-8,big5,大小寫均可 $from,原始讀出來的編碼,如UTF-8,BIG5,大小寫均可 mb_convert_encoding($str, "UTF-8"); //編碼轉換為utf-8 mb_convert_encoding($str, "UTF-8", "BIG5"); //原始編碼為BIG5轉UTF-8 mb_convert_encoding($str, "UTF-8", "auto"); //原始編碼不明,通過auto自動檢測,轉換UTF-8

[jQuery] 事件綁定在有著使用者自訂屬性的element上

在有著data-keyword_id屬性的<a>標籤上綁定事件 $("a[data-keyword_id]").bind("click",function(){ // do things }); http://stackoverflow.com/questions/8172322/how-to-bind-to-a-elements-data-attribute