first of all, this is not a duplicate question, I read all similar questions here find that I should check nd_mysqli on the server, I have a shared host server and I contact admin for enabling this driver, he told me that it's already enabled. PHP version is also set to highest available which is 7.2, Also because of the shared host, I can't access php.ini file to make changes. so here's my code for search thing on my website and I use prepared statements for this:
PHP
<?php session_start(); ?>
<?php include "./db.php"; ?>
<?php include "./functions.php"; ?>
<?php include "./header.php"; ?>
<nav>
<?php include "./navbar.php"; ?>
</nav>
<section id="main-section">
<div class="page-title">
<p>search result</p>
</div>
<div class="container">
<?php
if(isset($_POST['search'])){
$search_str = $_POST['search'];
$search = mysqli_real_escape_string($connection, $search_str);
if(strlen($search) > 0) {
$per_page = 12;
if(isset($_GET['page'])){
$page = $_GET['page'];
} else {
$page = 1;
}
if($page == "" || $page == 1) {
$page_1 = 0;
} else {
$page_1 = ($page * $per_page) - $per_page;
}
$item_count = "SELECT * FROM products WHERE (product_title) LIKE ? OR (product_cat) LIKE ? OR (product_brand) LIKE ? OR (product_info) LIKE ?";
$stmt = mysqli_stmt_init($connection);
if(!mysqli_stmt_prepare($stmt, $item_count)) {
echo "SQL statement failed!";
} else {
mysqli_stmt_bind_param($stmt, 'ssss', $search_str, $search_str, $search_str, $search_str);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$count = mysqli_num_rows($result);
$count_pages = ceil($count / $per_page) ;
}
if($count == 0) {
echo "<p class='noresult'>no result :(</p>";
} else {
$query = "SELECT * FROM products WHERE (product_title) LIKE ? OR (product_cat) LIKE ? OR (product_brand) LIKE ? OR (product_info) LIKE ? LIMIT $page_1,$per_page ";
$stmt = mysqli_stmt_init($connection);
if(!mysqli_stmt_prepare($stmt, $query)) {
echo "SQL statement failed";
} else {
mysqli_stmt_bind_param($stmt, 'ssss', $search_str, $search_str, $search_str, $search_str);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
}
while($row = mysqli_fetch_assoc($result)){
$product_id = $row['product_id'];
$product_cat = $row['product_cat'];
$product_title = shorterTitle($row['product_title']);
$product_brand = $row['product_brand'];
$product_main_image = $row['product_main_image'];
$product_size = toPersianNum($row['product_size']);
$product_colors = $row['product_colors'];
$product_material = $row['product_material'];
$product_info = shorterInf($row['product_info']);
$product_price = intval($row['product_price']);
$product_dir = str_replace(" ", "_", $product_title);
?>
.
.
.
this is the error I get when I try to search something:
Fatal error: Uncaught Error: Call to undefined function mysqli_stmt_get_result() in /home4/maketir/public_html/Includes/search.php:41 Stack trace: #0 {main} thrown in /home4/maketir/public_html/Includes/search.php on line 41
how can I fix this?