<分区>
我已经多次使用 mysqli_stmt_bind_param 函数。但是,如果我将试图防止 SQL 注入(inject)的变量分开,则会遇到错误。
这是一些代码示例:
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.
连接替换为另一个问号语句,制作另一个绑定(bind)参数语句,或添加到现有语句以防止 SQL 注入(inject)?
像这样或这样的某种形式:
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();
}