Kim Jaehyeon
0
Q:

sql injection

$value = "your value here";

try {
            $pdo = new PDO($dsn, $username, $password, $>drivers);
        } catch (\PDOException $e) {
            echo 'Connection Failed: ' . $e->getMessage();
        }
        
$sql = "INSERT INTO `my_db` SET `field` = ? ";
$stmt = $this->pdo->prepare($sql);
        $stmt->bindValue(1, $value, PDO::PARAM_STR);
        $stmt->execute();
        $stmt = null;
2
1 or 1=1 sfyan
-2
String tableName;
switch(PARAM):
  case "Value1": tableName = "fooTable";
                 break;
  case "Value2": tableName = "barTable";
                 break;
  ...
  default      : throw new InputValidationException("unexpected value provided" 
                                      
0

New to Communities?

Join the community