Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
基本的に私の質問は、数字の文字列があり、それをデータベースと比較する場合、それは安全で安全なチェック方法です。または、(すでに行っているように)文字列だけでなく数値変数もエスケープする必要がありますか?
例:
<?php $id = $_POST['id']; if(is_numeric($id)){ //database connectivity. } ?>
「データベース」はかなり一般的であるため、MySQLを使用していると想定します。$idクエリに挿入するときにエスケープされる(プリペアドステートメントを使用するか、できればプリペアドステートメントを使用することが望ましい)限り、安全ですmysql_real_escape_string。
$id
mysql_real_escape_string
"Id='であるTblから選択します"。(int)$ _POST['id']。"'"