SQL SELECT クエリを実行する前に、PHP 検索フォームでユーザー入力から特殊文字を削除する方法を見つけようとしています。
ユーザー入力を選択クエリ> mysql 5> Linuxに送信するPHP検索フォームがあります。選択クエリは、LIKE 一致の 1 つの列を調べ、結果を結果ページに戻します。データベースの列には特殊文字はなく、英数字のみです。
私のデータベースフィールド値は次のようになります 33345678DEP
ユーザーが 333-456*78DEP と入力した場合、特殊文字を削除するにはどうすればよいですか?
私はREGEXについて読みました - それが答えかもしれませんが、それを実装する方法がわかりません。
検索を実行するMY PHPコードは次のとおりです。
if (isset($_GET['InventoryByVendorForm'])) {
$colname_InventoryByVendorResults = $_GET['InventoryByVendorForm'];
}
mysql_select_db($database_ic3, $ic3);
$query_InventoryByVendorResults = sprintf("SELECT icCombinedSupplier_wrk.icMaster_icmKEY, icCombinedSupplier_wrk.icsSupplierID, icCombinedSupplier_wrk.icsPartNum, icCombinedSupplier_wrk.icsQuantityOnHand, icCombinedSupplier_wrk.icsCost, icCombinedSupplier_wrk.icsCore, icCombinedSupplier_wrk.icsLastInventoryUpdate, icMaster.icmLineCode, icAttributes.`icaPartslink#` AS icaPartslink FROM icMaster INNER JOIN (icCombinedSupplier_wrk INNER JOIN icAttributes ON icCombinedSupplier_wrk.icMaster_icmKEY = icAttributes.icMaster_icmKEY) ON icMaster.icmKEY = icCombinedSupplier_wrk.icMaster_icmKEY WHERE `icCombinedSupplier_wrk`.`icMaster_icmKEY` Like %s ORDER BY icMaster_icmKEY ASC", GetSQLValueString("%" . $colname_InventoryByVendorResults . "%", "text"));
私の最善の推測では、ステートメントの周りに REGEX [[alnum]] の使用を実装する必要があると思います。
$colname_InventoryByVendorResults = $_GET['InventoryByVendorForm']
検索ボックスのユーザー入力から英数字以外のすべての文字を削除するにはどうすればよいですか?