mysqli_fetch_array 与 prepared_statement 的等价物是什么?

what is the equivalent of mysqli_fetch_array for prepared_statement?

我正在尝试从 table 中获取一个简单单元格的字符串。 iv 这样做(没有准备陈述):

if($result_ur = mysqli_query($conn_ur, $sql_log)) {
    /* this is the problem */

    $row = mysqli_fetch_array($result_ur);

    /* here finishes my problem*/

    $lvl = $row['lvl'];
    $nombre = $row['nombre'];

    $username =$row['username'];
    $email = $row['email'];
    /*blablablabla more variables*/

    echo $username." <br>".$email."<br>";


    mysqli_free_result($result_ur);
    //-- ELSE DE NUM ROWS 

它就像一个魅力!但现在 iv 阅读了有关 sql 注入的信息,所以一位朋友告诉我(出于安全原因)我可以在 "preparing statements" 之前完成,这样我就可以逃避注入。

我真的输了 iv 完成了所有 iv 阅读但什么都没有... 我的服务器不允许 get_result();所以我的绑定结果是这样的

<?php 
    include dirname(__FILE__)."/conect_reg.php";

    $nombre = $_GET['nombre'];
    echo "variable ".$nombre.", working?<br>";
    if($nombre) {
        $checkuser = $conn_reg->prepare ("SELECT * FROM  `usus` WHERE `usuario` =  ?");
        $checkuser->bind_param("s", $nombre);
        $checkuser->execute();                  
        $checkuser->store_result();                 
        $checkuser_rows = $checkuser->num_rows; 

        /* Here is the problem */   
        if($checkuser != 0) {                   
            $checkuser_res = $checkuser->bind_result($id_d,$nombre_d,$paterno_d,$materno_d,$usuario_d,$pass_d,$email_d,$lvl_d,$telefono_d,$fecha_d,$code_d,$active_d,$profileimg_d);
            return $checkuser_res;
            $row = fetch($checkuser_res);
          /*  Here finish the problem    */
        }   
    }

    echo "working?<br>";

?>

它可以达到 "bind_result",(老实说我不知道​​我在做什么,我就像那个狗和电脑的模因)。

我需要的是使用 `echo $row['user'] 的等价物;喜欢 mysqli_fetch_array

if ($row['user'] = $user){
    echo "that ";
}

但我不知道如何用 "preparing statements" 和 "bind_result" 做到这一点。 编辑:使问题更全面。

bind_result 调用按 SELECT 语句列的顺序将 $row['user'] 分配给单个变量,这与您在 [=14= 中使用的数组形式相反].

等效功能如下:

$checkuser = $conn_reg->prepare ("SELECT `id`, `nombre`, `paterno`, `materno`, `usuario`, `pass`, `email`, `lvl`, `telefono`, `fecha`, `code`, `active`, `profileimg` FROM `usus` WHERE `usuario` =  ?"); 
$checkuser->bind_param("s", $nombre);
$checkuser->execute();
$checkuser->bind_result($id_d,$nombre_d,$paterno_d,$materno_d,$usuario_d,$pass_d,$email_d,$lvl_d,$telefono_d,$fecha_d,$code_d,$active_d,$profileimg_d);
if ($checkuser->fetch()) {
    echo $usuario_d . " Hello";
}