gpt4 book ai didi

php - 我可以在准备好的语句中参数化表名吗?

转载 作者:行者123 更新时间:2023-12-05 06:54:04 24 4
gpt4 key购买 nike

<分区>

我已经多次使用 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();
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com