0

I had use call_user_func_array and on my localhost the script work perfect but when i upload on server it give me 2 error and i do not know why .. can any body help me to get over it .It would be appreciated. thanks in advance

Errors below.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object

Fatal error: Uncaught Error: Call to a member function execute() on boolean

Small part of code is below which is related to these errors

<?php 
      $location_title="";
      $num_of_rows="";
      if(isset($_POST['search_forsale'])){
        $query="SELECT * FROM sales WHERE id>0";
        $params = array();
        if(!empty($_POST['location'])){
          $location=trim("%{$_POST['location']}%");
          $location_title=$_POST['location'];
          $query.=" AND lower(location) LIKE ?";
          $params[]=$location;
        }
        if(!empty($_POST['min_price'])){
          $min_price=$_POST['min_price'];
          $query.=" AND price>=?";
          $params[]=$min_price;
        }
        if(!empty($_POST['max_price'])){
          $max_price=$_POST['max_price'];
          $query.=" AND price<=?";
          $params[]=$max_price;
        }
        if(!empty($_POST['category'])){
          $category=$_POST['category'];
          $query.=" AND category=?";
          $params[]=$category;
        }
        if(!empty($_POST['bedrooms'])){
          $bedrooms=$_POST['bedrooms'];
          $query.=" AND bedrooms=?";
          $params[]=$bedrooms;
        }
        if(!empty($_POST['sort_by'])){
          $sort_by=$_POST['sort_by'];
          $query.=" ORDER BY ?";
          $params[]=$sort_by;
        }
        if(!empty($_POST['title'])){
          $title=trim("%{$_POST['title']}%");
          $query.=" AND lower(title) LIKE ?";
          $params[]=$title;
        }

        $param_types = '';                        
        foreach($params as $param){        
          if(is_int($param)){
            $param_types .= 'i';          
          }elseif(is_float($param)){
            $param_types .= 'd';           
          }elseif(is_string($param)){
            $param_types .= 's';        
          }else{
            $param_types .= 'b';     
          }
        }
        array_unshift($params, $param_types);
        $connect=Connect_db();
        $stmt = $connect->stmt_init();

        function refValues($arr){
          if(strnatcmp(phpversion(),'5.3')>=0){
              $refs = array();
              foreach($arr as $key => $value)
                $refs[$key] = &$arr[$key];
              return $refs;
          }
          return $arr;
        }
        **$stmt=$connect->prepare($query);
        call_user_func_array(array($stmt,'bind_param'),refValues($params));
        $execute_query=$stmt->execute();
        $result=$stmt->get_result();
        $num_of_rows=$result->num_rows;**

Bold part is main code where the error line showed

Shadow
  • 33,525
  • 10
  • 51
  • 64
david
  • 5
  • 2
  • 8

0 Answers0