php - How to pass an array of parameters to the bind_param? -


i'm getting folowing error:

warning: wrong parameter count mysqli_stmt::bind_param() 

i believe it's because i'm assigning parameters bind_param method wrong way. question how pass array of parameters bind_param?

this function:

function read($sql, $params) {    $parameters = array();    $results = array();     // connect    $mysql = new mysqli('localhost', 'root', 'root', 'db') or die('there problem connecting database. please try again later.');     // prepare    $stmt = $mysql->prepare($sql) or die('error preparing query');     // bind param ????????????    call_user_func_array(array($stmt, 'bind_param'), $params);     // execute    $stmt->execute();     // bind result    $meta = $stmt->result_metadata();     while ( $field = $meta->fetch_field() ) {       $parameters[] = &$row[$field->name];     }     call_user_func_array(array($stmt, 'bind_result'), $parameters);     // fetch    while( $stmt->fetch() ) {      $x = array();       foreach( $row $key => $val ) {         $x[$key] = $val;      }       $results[] = $x;   }    return $results; } 

this how call it:

$params = array('i'=>$get_release, 'i'=>$status); $result_set = read('select release_id, release_group_id, status_id, name, subname, description, released_day, released_month, released_year, country_id, note, is_master_release, seo_url, meta_description, is_purchased `release` release_id = ? , status_id = ?', $params); 

this looks wrong:

$params = array('i'=>$get_release, 'i'=>$status); 

from the docs:

note when 2 identical index defined, last overwrite first.

you're passing array 1 element , statement has 2 placeholders.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -