Troubleshooting of PHP errors: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:


使用者輸入內容,內容可能是
使用者輸入內容,內容可能是
* 空值
* 空值 <== 對策: [http://php.net/manual/en/function.trim.php PHP: trim] 或 jQuery [http://api.jquery.com/jQuery.trim/ $.trim('string')]
* 包含單引號 '
* 包含單引號 '
* 包含雙引號 "
* 包含雙引號 "
Line 13: Line 13:
* 內容的前後有空白 (可用[http://php.net/manual/en/function.trim.php trim]函數移除空白)
* 內容的前後有空白 (可用[http://php.net/manual/en/function.trim.php trim]函數移除空白)
* 超出預期的內容長度
* 超出預期的內容長度
* 單值或空值


操作順序
操作順序

Revision as of 23:38, 24 March 2013

檔案操作有關


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

  • 空值 <== 對策: PHP: trim 或 jQuery $.trim('string')
  • 包含單引號 '
  • 包含雙引號 "
  • 包含換行符號
  • 內容的前後有空白 (可用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 "變數名稱"

references

  1. php - Create a folder if it doesn't already exist - Stack Overflow code snippet: mkdir('path/to/directory', 0755, true);