我向一个人付钱让我在我的网站上搜索代码。所以在使用php 5.3的localhost上,它的所有正常搜索都运行良好,一切都很好。但当我将文件上传到我的网站主机时,search.php会给我一个错误“致命错误:调用未定义的方法mysqli_stmt :: get_result()”我的Search.php代码是:
<?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();
?>
答案 0 :(得分:1)
正如mysqli::get_result()
所述:
仅限MySQL本机驱动程序
仅适用于mysqlnd。
点击链接到introduction:
MySQL Native Driver是MySQL客户端库(libmysqlclient)的替代品。 MySQL Native Driver是PHP 5.3.0中官方PHP源代码的一部分。
您还可以查看installation instructions。