undertaker Posted August 12, 2013 Share Posted August 12, 2013 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 More sharing options...
mac_gyver Posted August 12, 2013 Share Posted August 12, 2013 you already have a thread on this forum for this problem, where someone showed what the code needed to be. you seem to be just randomly throwing code up against the wall to see what sticks. Link to comment https://forums.phpfreaks.com/topic/281098-mysqli-bind_param-reference/#findComment-1444644 Share on other sites More sharing options...
undertaker Posted August 12, 2013 Author Share Posted August 12, 2013 I am sorry, i havent noticed you changed my code there. Thought it was just a quote of my post.I tried to rewrite the code and present my problem better in a new post since you told me the previous looked like piece of *. Link to comment https://forums.phpfreaks.com/topic/281098-mysqli-bind_param-reference/#findComment-1444646 Share on other sites More sharing options...
undertaker Posted August 12, 2013 Author Share Posted August 12, 2013 Solved here: http://forums.phpfreaks.com/topic/281071-mysqli-dynamic-bind-param-parameters/ Link to comment https://forums.phpfreaks.com/topic/281098-mysqli-bind_param-reference/#findComment-1444664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.