mysqli_stmt_bind_param 関数を数回使用しました。ただし、SQL インジェクションから保護しようとしている変数を分離すると、エラーが発生します。
コードサンプルを次に示します。
function insertRow( $db, $mysqli, $new_table, $Partner, $Merchant, $ips, $score, $category, $overall, $protocol )
{
$statement = $mysqli->prepare("INSERT INTO " .$new_table . " VALUES (?,?,?,?,?,?,?);");
mysqli_stmt_bind_param( $statment, 'sssisss', $Partner, $Merchant, $ips, $score, $category, $overall, $protocol );
$statement->execute();
}
.$new_table.
SQLインジェクションから保護するために、連結を別の疑問符ステートメントに置き換えたり、別のバインドパラメーターステートメントを作成したり、既存のものに追加したりすることは可能ですか?
このように、またはこれのいくつかの形式:
function insertRow( $db, $mysqli, $new_table, $Partner, $Merchant, $ips, $score, $category, $overall, $protocol )
{
$statement = $mysqli->prepare("INSERT INTO (?) VALUES (?,?,?,?,?,?,?);");
mysqli_stmt_bind_param( $statment, 'ssssisss', $new_table, $Partner, $Merchant, $ips, $score, $category, $overall, $protocol );
$statement->execute();
}