Hi,
You missed to prepare the statement. Please try below code.
$stmt = $conn->prepare("SELECT state FROM branch_info WHERE state = ? AND branch = ?");
if($stmt === false)
{
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->errno . ' ' . $conn->error, E_USER_ERROR);
}
$param1=$_POST["states"];
$param2=$_POST["exstbr"];
$stmt->bind_param('ss',$param1,$param2);
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_array(MYSQLI_ASSOC))
{
if($row["state"] > 0)
echo "Already Exists";
}
$stmt->close();
Hoping $conn is your connection object and it should look like below.
$conn = new mysqli($servername, $username, $password, $dbname);
Hope this will help you :).