我可以在準(zhǔn)備好的語句中參數(shù)化表名嗎?我多次使用mysqli_stmt_bind_param函數(shù)。但是,如果我將試圖防止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.與另一個問號語句連接,創(chuàng)建另一個BIND參數(shù)語句,還是添加到現(xiàn)有語句中以防止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();}
查看完整描述