How to run the bind_param() statement in PHP?

后端 未结 3 817
执念已碎
执念已碎 2020-12-01 19:20

I\'m trying to make the following code work but I can\'t reach the execute() line.

$mysqli = $this->C         


        
3条回答
  •  自闭症患者
    2020-12-01 19:37

    When binding parameters you need to pass a variable that is used as a reference:

    $var = 1;
    
    $stmt->bind_param('i', $var);
    

    See the manual: http://php.net/manual/en/mysqli-stmt.bind-param.php

    Note that $var doesn't actually have to be defined to bind it. The following is perfectly valid:

    $stmt->bind_param('i', $var);
    
    foreach ($array as $element)
    {
    
        $var = $element['foo'];
    
        $stmt->execute();
    
    }
    

提交回复
热议问题