很多時候我們在下SQL語言時出錯卻一直找不出原因, 很多時候是因為在MYSQL內的COLUMN使用了reserved word 而造成的. 以下為MYSQL 的reserved word, 如果你在命名table.column時就要儘可能避開使用這些保留變數了.

ACCESSIBLE 	ADD 	ALL
ALTER 	ANALYZE 	AND
AS 	ASC 	ASENSITIVE
BEFORE 	BETWEEN 	BIGINT
BINARY 	BLOB 	BOTH
BY 	CALL 	CASCADE
CASE 	CHANGE 	CHAR
CHARACTER 	CHECK 	COLLATE
COLUMN 	CONDITION 	CONSTRAINT
CONTINUE 	CONVERT 	CREATE
CROSS 	CURRENT_DATE 	CURRENT_TIME
CURRENT_TIMESTAMP 	CURRENT_USER 	CURSOR
DATABASE 	DATABASES 	DAY_HOUR
DAY_MICROSECOND 	DAY_MINUTE 	DAY_SECOND
DEC 	DECIMAL 	DECLARE
DEFAULT 	DELAYED 	DELETE
DESC 	DESCRIBE 	DETERMINISTIC
DISTINCT 	DISTINCTROW 	DIV
DOUBLE 	DROP 	DUAL
EACH 	ELSE 	ELSEIF
ENCLOSED 	ESCAPED 	EXISTS
EXIT 	EXPLAIN 	FALSE
FETCH 	FLOAT 	FLOAT4
FLOAT8 	FOR 	FORCE
FOREIGN 	FROM 	FULLTEXT
GRANT 	GROUP 	HAVING
HIGH_PRIORITY 	HOUR_MICROSECOND 	HOUR_MINUTE
HOUR_SECOND 	IF 	IGNORE
IN 	INDEX 	INFILE
INNER 	INOUT 	INSENSITIVE
INSERT 	INT 	INT1
INT2 	INT3 	INT4
INT8 	INTEGER 	INTERVAL
INTO 	IS 	ITERATE
JOIN 	KEY 	KEYS
KILL 	LEADING 	LEAVE
LEFT 	LIKE 	LIMIT
LINEAR 	LINES 	LOAD
LOCALTIME 	LOCALTIMESTAMP 	LOCK
LONG 	LONGBLOB 	LONGTEXT
LOOP 	LOW_PRIORITY 	MASTER_SSL_VERIFY_SERVER_CERT
MATCH 	MEDIUMBLOB 	MEDIUMINT
MEDIUMTEXT 	MIDDLEINT 	MINUTE_MICROSECOND
MINUTE_SECOND 	MOD 	MODIFIES
NATURAL 	NOT 	NO_WRITE_TO_BINLOG
NULL 	NUMERIC 	ON
OPTIMIZE 	OPTION 	OPTIONALLY
OR 	ORDER 	OUT
OUTER 	OUTFILE 	PRECISION
PRIMARY 	PROCEDURE 	PURGE
RANGE 	READ 	READS
READ_WRITE 	REAL 	REFERENCES
REGEXP 	RELEASE 	RENAME
REPEAT 	REPLACE 	REQUIRE
RESTRICT 	RETURN 	REVOKE
RIGHT 	RLIKE 	SCHEMA
SCHEMAS 	SECOND_MICROSECOND 	SELECT
SENSITIVE 	SEPARATOR 	SET
SHOW 	SMALLINT 	SPATIAL
SPECIFIC 	SQL 	SQLEXCEPTION
SQLSTATE 	SQLWARNING 	SQL_BIG_RESULT
SQL_CALC_FOUND_ROWS 	SQL_SMALL_RESULT 	SSL
STARTING 	STRAIGHT_JOIN 	TABLE
TERMINATED 	THEN 	TINYBLOB
TINYINT 	TINYTEXT 	TO
TRAILING 	TRIGGER 	TRUE
UNDO 	UNION 	UNIQUE
UNLOCK 	UNSIGNED 	UPDATE
USAGE 	USE 	USING
UTC_DATE 	UTC_TIME 	UTC_TIMESTAMP
VALUES 	VARBINARY 	VARCHAR
VARCHARACTER 	VARYING 	WHEN
WHERE 	WHILE 	WITH
WRITE 	XOR 	YEAR_MONTH
ZEROFILL

The following are new reserved words in MySQL 5.1:

ACCESSIBLE 	LINEAR 	MASTER_SSL_VERIFY_SERVER_CERT
RANGE 	READ_ONLY 	READ_WRITE

參考資料: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

環境: PHP4 + Apache4 + Windows
函數: iconv (http://tw.php.net/iconv)

最近有幫舊電腦寫程式,
發現PHP4預設不支援iconv, 先別擔心升級PHP5所帶來的其他風險,
其實是有辦法可以在PHP4下解決的:

1. 在C:\php\dll 底下有個 php_iconv.dll
2. 將此DLL放到 c:\Windows\system32\ 底下
3. 在C:\php\php.ini 將 extension 下的 php_iconv.dll Uncomment掉(把分號拿掉)
4. 重新啟動Apache.
5. It works!

在網路上找到的blink不是只能用於IE就是只相容於FF, 於是自己嘗試寫了一個JavaScript Blink的功能.
在IE8 及FF測試都沒問題. 閃爍的頻率在SetTimeout裡面可以設定, 1000表示1秒, 2000為2秒, 以此類推.




征才 


剛在JavaScript寫程式時,
發現我的Ajax功能在FireFox可以跑成功, Firebug也偵測不出問題,
但用IE時卻出現錯誤, 顯示說某某行找不到物件.
後來去找了很久才知道原來問題出在一個平時很少注意的地方:

乍看之下可能會覺得以上兩行沒有甚麼差別, 但其實問題就在type的部分,
在FF是可以辨識成功的, 但在IE(測試環境IE8)的情況下就讀取不到Javascript.
所以以後要多注意囉.

PHP的File Upload功能固然強大, 但要滿足大量檔案上傳的需求仍需要搭配AJAX或是Flash object, 這篇文章就是要介紹一個好用的Flash Uploader, 讓你可以直接從Windows, 在同一個目錄下選取要上傳的檔案, 達成輕鬆上傳的目的.

SwfUpload

官方網站: http://swfupload.org/

範例: http://demo.swfupload.org/v220/index.htm

index.php FLASH檔案上傳的頁面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5″ />
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="default.css" rel="stylesheet" type="text/css" />
<title>測試</title>
<script type="text/javascript" src="swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/swfupload.swfobject.js"></script>
<script type="text/javascript" src="js/swfupload.queue.js"></script>
<script type="text/javascript" src="js/fileprogress.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript">
var swfu;

SWFUpload.onload = function () {
var settings = {
flash_url : "swfupload/swfupload.swf",
upload_url: "upload.php", //負責處理上傳的PHP檔案
post_params: {
"PHPSESSID" : "NONE",
"HELLO-WORLD" : "Here I Am",
".what" : "OKAY"
},
file_size_limit : "100 MB",
file_types : "*.*",
file_types_description : "All Files",
file_upload_limit : 100,
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
debug: false,

// Button Settings
button_image_url : "images/XPButtonUploadText_61x22.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 61,
button_height: 22,

// The event handler functions are defined in handlers.js
swfupload_loaded_handler : swfUploadLoaded,
file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_start_handler : uploadStart,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
queue_complete_handler : queueComplete,    // Queue plugin event

// SWFObject settings
minimum_flash_version : "9.0.28″,
swfupload_pre_load_handler : swfUploadPreLoad,
swfupload_load_failed_handler : swfUploadLoadFailed
};

swfu = new SWFUpload(settings);
}

</script>

</head>

<body>

<form id="form1″ action="index.php" method="post" enctype="multipart/form-data">
<div id="divSWFUploadUI">
<div class="fieldset  flash" id="fsUploadProgress">
<span class="legend">Upload Queue</span>
</div>
<p id="divStatus">0 Files Uploaded</p>
<p>
<span id="spanButtonPlaceholder"></span>
<input id="btnCancel" type="button" value="Cancel All Uploads" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
<br />
</p>
</div>
<noscript>
<div style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966;  padding: 10px 15px;">
We’re sorry.  SWFUpload could not load.  You must have JavaScript enabled to enjoy SWFUpload.
</div>
</noscript>
<div id="divLoadingContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
SWFUpload is loading. Please wait a moment…
</div>
<div id="divLongLoading" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
SWFUpload is taking a long time to load or the load has failed.  Please make sure that the Flash Plugin is enabled and that a working version of the Adobe Flash Player is installed.
</div>
<div id="divAlternateContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
We’re sorry.  SWFUpload could not load.  You may need to install or upgrade Flash Player.
Visit the <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Adobe website</a> to get the Flash Player.
</div>
</form>

</body>

</html>

upload.php , 負責處理上傳後的PHP

$upload_name = "Filedata";

if(isset($_FILES[$upload_name])) {

$filename = $_FILES[$upload_name]['name'];
copy($_FILES[$upload_name]['tmp_name'], $filename);

}

PHP Mailer

$mail = new PHPMailer();
mb_internal_encoding('UTF-8'); //避免主題亂碼

//Function
function MyMailer($mail, $to, $mailbody, $subject, $attachtrue, $filename) {

global $smtpsecure2, $smtphost2, $smtpport2;
global $username2, $password2, $replyto2;
global $from2, $fromname2;

$mail->IsSMTP();
$mail->SMTPAuth   = true;  // enable SMTP authentication
$mail->SMTPSecure = $smtpsecure2;
$mail->Host       = $smtphost2;
$mail->Port       = $smtpport2;
$mail->Username   = $username2;
$mail->Password   = $password2;
$mail->AddReplyTo($replyto2,$fromname2);
$mail->From       = $from2;
$mail->FromName   = $fromname2;
$mail->Subject    = mb_encode_mimeheader($subject, "UTF-8");
$mail->WordWrap   = 50; // set word wrap
$mail->MsgHTML($mailbody);
$mail->AddAddress($to, "");
//charset
$mail->CharSet="UTF-8";

if($attachtrue == 1) {

for($i = 0; $i < count($filename); $i++) {
$mail->AddAttachment("attach/".$filename[$i]);
}
}

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo '<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />';
echo "Error: " . $mail->ErrorInfo;
} else {
echo '<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />';
echo "Success!";
}

}

製作一個Javascript EDITOR, 可以直接存取Windows 系統 ClipBoard(剪貼簿)的資料/圖片,

如果沒有限定瀏覽器當然最好, 但如果功能只能在IE使用也OK.

以下的CODE參考自某論壇,還沒有嘗試過,先在此記錄一下:

function SetToClipboard(text) {
if (isIE)
window.clipboardData.setData("Text", text);
else if (isFF) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (every) { window.alert(jsresClipboardNotAllowed); return null;}
var clip = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
clip.copyString(text);
}
}

如果在editor能夠進行裁剪更佳~

還沒實作過, 這個IDEA如果可以實現, 在部落格寫教學將會非常方便. (不用一直使用圖片編輯器來處理圖像)

1. 在linux輸入指令: crontab -e 進行系統排程編輯模式

2. 格式大概如下, 前面5個欄位分別是是執行的日期時間(分 時 日 月 年), 後面的路徑是要執行的程式, 以下的意思是指每天的凌晨12點會執行一次此程式:

 0 0 * * * /usr/local/www/awstats/cgi-bin/awstats.sh

3. 現在我們要排程執行PHP網頁, 因此需要用LINUX的PHP程式來執行PHP網頁, 指令如下:

30 23 * * * /usr/local/bin/php /home/xxx/public_html/mytesting.php >> /host/cron.log 2>&2

以上的指令含意是, 每天的晚上11點30分會使用PHP程式(路徑在/usr/local/bin/)來執行PHP網頁(路徑在/home/xxx/public_html/), 而後面的意思是執行完畢後的紀錄檔會延伸儲存在 /host/cron.log 裡面, 讓你知道執行的結果, 否則執行的狀況你是沒辦法直接看到的.(使用 * 的意思是不管何年何月何日, 若指定日期, 那就表示只會在該日期執行一次) 所以若要系統每天固定時間內替你執行程式, 就要把格式寫清楚囉, crontab的時間格式如下:

field              allowed values
—–             ————–
minute            0-59
hour               0-23
day of month   1-31
month            1-12 (or names, see below)
day of week    0-7 (0 or 7 is Sun, or use names)

 若想知道更詳細的資料, 可以輸入 man 5 crontab, 參考詳細的說明. 除此之外, 要例行執行程式, 寫法也可以如下:

string            meaning
——           ——-
@reboot        Run once, at startup.
@yearly         Run once a year, "0 0 1 1 *".
@annually      (same as @yearly)
@monthly       Run once a month, "0 0 1 * *".
@weekly        Run once a week, "0 0 * * 0″.
@daily           Run once a day, "0 0 * * *".
@midnight      (same as @daily)
@hourly         Run once an hour, "0 * * * *".

如果我想要每分鐘執行一次, 要怎麼寫?

*/1 * * * * /usr/local/bin/php /home/xxx/public_html/mytesting.php >> /host/cron.log 2>&2

*/1 就是讓你連續每分鐘執行一次的關鍵寫法.