Troubleshooting of PHP errors: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
* 可否讀取或寫入:例如 imagejpeg($canvas, $filename, 100); 沒有顯示錯誤訊息,則需要
* 可否讀取或寫入:例如 imagejpeg($canvas, $filename, 100); 沒有顯示錯誤訊息,則需要
** 檢查暫存目錄是否可以寫入 [http://stackoverflow.com/questions/1520956/php-way-to-find-the-web-servers-temp-path upload - PHP way to find the web server's temp path? - Stack Overflow]
** 檢查暫存目錄是否可以寫入 [http://stackoverflow.com/questions/1520956/php-way-to-find-the-web-servers-temp-path upload - PHP way to find the web server's temp path? - Stack Overflow]
** 檢查該檔案所在該目錄是否已經建立,若未建立則需要建立 [http://php.net/manual/en/function.mkdir.php mkdir],並設定可以寫入。如果是巢狀的多層目錄,則需要啟用 $recursive
** 檢查該檔案所在該目錄是否已經建立,若未建立則需要建立 [http://php.net/manual/en/function.mkdir.php mkdir],並設定可以寫入。如果是巢狀的多層目錄,則需要啟用 $recursive <ref>[http://stackoverflow.com/questions/2303372/create-a-folder-if-it-doesnt-already-exist php - Create a folder if it doesn't already exist - Stack Overflow]  code snippet: <nowiki>mkdir('path/to/directory', 0755, true);</nowiki> </ref>
** 檢查該檔案是否可以寫入 [http://php.net/manual/en/function.is-writable.php is_writable]
** 檢查該檔案是否可以寫入 [http://php.net/manual/en/function.is-writable.php is_writable]



Revision as of 14:22, 19 March 2013

檔案操作有關


使用者輸入內容,內容可能是

  • 空值
  • 包含單引號 '
  • 包含雙引號 "
  • 包含換行符號
  • 內容的前後有空白 (可用trim函數移除空白)
  • 超出預期的內容長度
  • 單值或空值

操作順序

  • 使用者的操作順序,可能不按照功能設計的順序
  • 沒有選取任何項目,就提交(submit)或操作表格

執行PHP時顯示原始碼的錯誤

  • 確認伺服器是否能執行 PHP。驗證: phpinfo
  • 如果 PHP 使用 short tag語法撰寫,則 php.ini 檔案 需要開啟 short_open_tag = Off -> On

錯誤訊息: ERROR: 00000::

  • 原因: 想要刪除的資料不在 MySQL 資料庫內,進行刪除時,會發生的錯誤。
  • 解決方法: 先檢查該資料是否存在,再進行刪除。

錯誤訊息:

PHP Warning:  phpinfo() has been disabled for security reasons in /path/to/phpinfo.php on line xx
  • 原因: 網管關閉使用 phpinfo
  • 替代解決方法 for Linux Os linux.png : 使用 linux command /path/to/bin/php -i | grep "變數名稱"
  1. php - Create a folder if it doesn't already exist - Stack Overflow code snippet: mkdir('path/to/directory', 0755, true);