PHP Search Broken Results [duplicate]

I’m trying to create a search system for my website that brings up the search itself and or any matching to what the user is searching.
This is my code

<?php 
  $db = mysqli_connect("localhost", "root", "", "db");
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

  $search = $_GET['search'];
  $sql = "SELECT * FROM posts WHERE Name LIKE '%$search%'";
  $result = mysqli_query($db, $sql);
  $row = mysqli_fetch_array($result);
  $count = mysqli_num_rows($result);
  if ($count == 0) {
    echo "No results found";
  } else {
    while ($row = mysqli_fetch_array($result)) {
      echo "<div class='post'>";
      echo "<img src='images/".$row['Image']."'>";
      echo "<h1>" . $row['Name'] . "</h1>";
      echo "<a href='" . $row['Link'] . "' target='_blank' rel='noopener noreferrer'>Download</a>";
      echo "<button id='report' type='submit'>Report broken link</a>";
      echo "</div>";
    }
  }
?>

It brings up the searches fine but it displays a error “( ! ) Notice: Undefined index: search in C:wamp64wwwonlyfanssearch.php on line 32”. Removing the $search breaks the entire thing so im unsure why there is a error if it works but removing it breaks it all. The search HTML itself is just a form with a GET method and action leading to search.php