-2

prepare statement works fine. but if i use the bellow function for prepare statement, then it return empty result. My code:

//prepare statement * all column
function prepare_select_stmt($link, $sql, $param_type, array $param){
  $num_param = strlen($param_type);
  $link->stmt_init();
  $stm = $link->prepare($sql);
  $bindParam = '$stm->bind_param($param_type,';
  for($i=0;$i<=$num_param-1;$i++){
    $bindParam.='$param['.$i.'],';
  }
$bindParam = rtrim($bindParam,',').');';
eval($bindParam);

//$stm->bind_param($param_type, $param);
$stm->execute();
$stm->store_result();

$meta = $stm->result_metadata();
$bindResult = '$stm->bind_result(';
while($columnName = $meta->fetch_field()){
    $bindResult .= '$result["'.$columnName->name.'"],';
}
$bindResult = rtrim($bindResult,',').');';
eval($bindResult);


$numRows= $stm->num_rows();
  if($numRows>0){

    $stm->fetch();
    return array($numRows,$result);
  }else{
    return array($numRows,array()); //empty array() means no result
  }
  $stm->close();
}

This function works fine in local server but return zero result in remote server. why?

M Hossain
  • 1
  • 2

1 Answers1

0

If a function work fine on one server and not on another it's generally that you don't have this function, a not readable files etc...

So check the log you can also trace with GDB

Regards.