我不知道爲什麼,但這不起作用。mysqli_stmt :: bind_param()期望參數1是字符串,給定數組[解決]
array_unshift($params,$types);
if($stmt = $conn->prepare($sql)){
call_user_func_array(array($stmt, 'bind_param'), refValues($params));
$stmt->execute();
現在它說:
警告:mysqli_stmt :: bind_param()預計參數1爲字符串,給定的數組...
那麼,什麼是錯,此代碼?
function refValues($arr){
if(strnatcmp(phpversion(),'5.3') >= 0){ //Reference is required for PHP 5.3
$refs = array();
foreach($arr as $key => $value){
$refs[$key] = &$arr[$key];
}
return $refs;
}
return $arr;
}
refValues($ params)的print_r;
Array ([0] => Array ([0] => i [1] => i [2] => i [3] => i [4] => i [5] => i [6] => i [7] => i [8] => i [9] => s [10] => i [11] => i [12] => i [13] => i [14] => i [15] => i [16] => i [17] => i [18] => i [19] => i [20] => i [21] => i) [1] => 1 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 1241 [9] => [10] => [11] => 1 [12] => [13] => [14] => [15] => 432 [16] => 243 [17] => 0 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 78)
這裏的解決方案: 我剛剛破滅的$types
陣列。所以然後第一個參數是一個字符串,而不是一個數組了。
又是什麼使誤差不夠清楚? – hassan
@hassan哪一個是「參數1」? – pandaNine
@pandaNine'refValues($ params)'。 – BenM