这段代码出了什么问题,我收到有关意外'$ result'的消息?我无法摆脱它。我搜索了很多关于这个问题,但没有找到解决方案。
<?php
//error_reporting(0);
if(isset($_REQUEST['v']) && !empty($_REQUEST['v'])){
$conx = mysqli_connect("localhost", "root", "mypass", "country_db");
if (!$conx) {
echo "Error connecting database!";
exit;
}
$search = $_REQUEST['v'];
$query = "SELECT `country_name` FROM `apps_countries` WHERE `country_name` LIKE '$search%'";
$result = mysqli_query($conx, $query); // here is the error
if (mysqli_num_rows($result) > 0) {
while ($d = mysqli_fetch_assoc($result)) {
echo $d['country_name'];
}
}
else{
echo "Nothing matched with your query";
}
}
else{
echo "No data received from the server";
}
?>