Last active
December 18, 2021 01:43
-
-
Save Shakil-Shahadat/457c96accc1b8f46daaa0edde089120c to your computer and use it in GitHub Desktop.
Escape an Array in Easiest Way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// For MySQL | |
// Escape $_GET elements | |
foreach ( $_GET as $key => $value ) | |
{ | |
$_GET[ $key ] = $db->escape_string( $_GET[ $key ] ); | |
} | |
// Escape $_POST elements | |
foreach ( $_POST as $key => $value ) | |
{ | |
$_POST[ $key ] = $db->escape_string( $_POST[ $key ] ); | |
} | |
// For SQLite | |
// Escape $_GET elements | |
foreach ( $_GET as $key => $value ) | |
{ | |
$_GET[ $key ] = $db->escapeString( $_GET[ $key ] ); | |
} | |
// Escape $_POST elements | |
foreach ( $_POST as $key => $value ) | |
{ | |
$_POST[ $key ] = $db->escapeString( $_POST[ $key ] ); | |
} |
Author
Shakil-Shahadat
commented
Dec 18, 2021
- Move this to miscellaneous.php.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment