0

What is going wrong with this code and I get this message about unexpected '$result' ??? I can't get rid of it. I searched a lot about this issue but didn't find a solution.

<?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";
}

?>
Danis35
  • 53
  • 1
  • 1
  • 8

0 Answers0