0

I pay to a guy to make me a code for search in my website. So on localhost using php 5.3 all its okay search is running good and everything its good. But when i upload the files to my web host the search.php get me a error " Fatal error: Call to undefined method mysqli_stmt::get_result() " My Search.php code is:

<?php
$stype = 0;
if (isset($_GET['s']) && $_GET['s']){
    $search=$_GET['s'];
    $stype += 1;
}
if (isset($_GET['min']) && $_GET['min'] && 
    isset($_GET['max']) && $_GET['max']){
    $pricemin=$_GET['min'];
    $pricemax=$_GET['max'];
    $stype +=2;
}

if (!$stype) {
    echo "Required parameter(s) missing. Please be sure to fill desired field(s). 

    <a href=\"#\" onclick=\"history.go(-1)\">Go Back</a>"

    ;
    exit;
}
/* connect to the database*/
$db = new mysqli("localhost", "XXX", "XXX", "XXX");
/* check connection */
if ($db->connect_errno) {
    echo "Connection failed: " . $db->connect_error;
    exit();
}


$query="SELECT * FROM `filmi` WHERE ";
if ($stype == 1) {
    $query .= " (`nomer` rlike ? OR `title` rlike ? OR `kategoriq` rlike ?) ";
} elseif ($stype == 2) {
    $query .= " `seriq` BETWEEN ? AND ? ";
} elseif ($stype == 3) {
    $query .= " (`nomer` rlike ? OR `title` rlike ? OR `kategoriq` rlike ?) AND `seriq` BETWEEN ? AND ?";
}
$query .= " ORDER BY seriq asc";
/* create a prepared statement */
$stmt = mysqli_stmt_init($db);
if (!$stmt = $db->prepare($query)) {
    //handle error here;
    echo "Error preparing statement.";
    exit;
}
/* bind parameters for markers */
if ($stype == 1) {
    $stmt->bind_param("sss", $search, $search, $search);
} elseif ($stype == 2) {
    $stmt->bind_param("dd", $pricemin, $pricemax);
} elseif ($stype == 3) {
    $stmt->bind_param("sssdd", $search, $search, $search, $pricemin, $pricemax);
}
/* execute query */
$stmt->execute();
/* get result */
 $result = $stmt->get_result();

if ($result) {
/* now you can fetch the results into an assoc array */
    while ($row = $result->fetch_assoc()) {
        echo " contenct " ;}
}
/* close statement */
$stmt->close();
/* close db connection */
$db->close();
?>
tshepang
  • 10,772
  • 21
  • 84
  • 127
  • Possible duplicate of [Call to undefined method mysqli\_stmt::get\_result](https://stackoverflow.com/questions/8321096/call-to-undefined-method-mysqli-stmtget-result) – Fabian N. Sep 01 '18 at 09:55

1 Answers1

1

As documented under mysqli::get_result():

MySQL Native Driver Only

Available only with mysqlnd.

Following the link through to the introduction:

MySQL Native Driver is a replacement for the MySQL Client Library (libmysqlclient). MySQL Native Driver is part of the official PHP sources as of PHP 5.3.0.

You might also take a look at the installation instructions.

eggyal
  • 113,121
  • 18
  • 188
  • 221