Jump to content

MySQLi bind_param() reference


undertaker

Recommended Posts

I am trying to pass several parameters dynamically to the bind_param() function.

Here is the error i receive:

Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given
$con = new mysqli('localhost',USER,PASS,DBS);

if(mysqli_connect_errno()) {
error(mysqli_connect_errno());
}

$con -> set_charset("utf8");

/*inside*/

$type='';

$query='SELECT bugID FROM bug';

if(!empty($_GET['cena'])) {

    $build[]='uCena=?';

    $type.='i';
    $val[]=$_GET['cena'];

}

if(!empty($_GET['popust'])) {

    $build[]='uPopust=?';

    $type.='i';
    $val[]=$_GET['popust'];

}

if(!empty($build)) {

    echo $query .= ' WHERE '.implode(' AND ',$build);
}

$new = array_merge(array($type),$val);
foreach($new as $key => $value)
{
    $tmp[$key]=&$new[$key];

    }

echo '<br/><br/>';

foreach ($new as $new ){

    echo "$new<br/>";
}

if ($count = $con->prepare($query)) {

    call_user_func_array(array($count,'bind_param'),$tmp);
    $count->execute();
    $cres = $count->fetch_row();

    $count -> close();

} else error($con->error);


/*inside*/

$con -> close();
Link to comment
https://forums.phpfreaks.com/topic/281098-mysqli-bind_param-reference/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.