0

So I have been looking at this code now for many months on and off and get the error mysqli_bind_param() fatal error and assume that a variable is missing or something can anyone offer any help?

public function getItems_paged($startIndex, $numItems) {

    $stmt = mysqli_prepare($this->connection, "SELECT clients.id, clients.fname, clients.lname, clients.sex, clients.country, clients.town, clients.dateofbirth, clients.monthofbirth, clients.yearofbirth
    FROM clients
    ORDER BY id DESC LIMIT ?, ?");
    $this->throwExceptionOnError();

    mysqli_bind_param($stmt, 'ii', $startIndex, $numItems);
    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    $rows = array();

    mysqli_stmt_bind_result($stmt, $row->id,$row->fname,$row->lname,$row->sex,$row->country,$row->town,$row->dateofbirth,$row->monthofbirth,$row->yearofbirth);

    while (mysqli_stmt_fetch($stmt)) {
      $row->fname = ucfirst(substr($row->fname,0,1));
      $row->lname = ucfirst($row->lname);
      $row->town = ucfirst($row->town);
      $row->lname = (($row->fname) . " " . ($row->lname));
      $row->yearofbirth = GetAge($row->dateofbirth. '-' .$row->monthofbirth. '-' .$row->yearofbirth);
      $row->Pic_loc = "";
      $row->Pic_loc= "IMAGES/".($row->id)."/image01.jpg";
      $rows[] = $row;
      $row = new stdClass();

      mysqli_stmt_bind_result($stmt, $row->id,$row->fname,$row->lname,$row->sex,$row->country,$row->town,$row->dateofbirth,$row->monthofbirth,$row->yearofbirth);

    }

    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);

    return $rows;
}
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
  • possible duplicate of [Mysqli update throwing Call to a member function bind\_param() error](http://stackoverflow.com/questions/15447133/mysqli-update-throwing-call-to-a-member-function-bind-param-error) – Giacomo1968 May 03 '14 at 23:10
  • Did you read this: “This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.” http://www.php.net/manual/en/function.mysqli-bind-param.php – Giacomo1968 May 03 '14 at 23:15
  • There's not really much help we can be here. You're calling `mysqli_bind_param` with parameters that are being passed into the function. If you're getting an intermittent error, that suggests that sometimes, when this function is called, it's not getting the correct information in the correct format. – andrewsi May 03 '14 at 23:54
  • Thanks JakeGould at first i was like yeah i know that and then four hours later worked out that i had upgraded my php to 5.4 and as soon as i downgraded it all worked cheers - just need to work out that if i upgrade again what will i need to do to replace mysqli_bind_param – WhiteFinger May 04 '14 at 14:07

0 Answers0