title: PHP string comparison to a txt
body: <p>The <code>$search</code> is a string of variables made from text inputs in a form. I am looking to see if that string is found in a txt file. I think something is wrong with my regex but I am not sure. </p>
  
  <p>An existing entry to the text file would look like this <code>Title%Author%ISBN%Publisher%Year</code>. </p>
  
  <p>My issue is that when I submit the form it goes to a blank page. </p>
  
  <pre><code>    elseif ($inquiry=='search') {
  
          $file= fopen("database.txt", "r") or die("File was not found on server"); 
  
          $search =  "/^[$Title."%".$Author."%".$ISBN."%".$Publisher."%".$Year]/i";
  
          //search function
          // What to look for
  
          // open and Read from file
          $lines = file('database.txt');//array
  
          foreach($lines as $line) {
              // Check if the line contains the string we're looking for, and print if it does
              if(preg_match($search, $line)) {
                  echo $line;
              } else {
                  echo "Search not found";
              }
          }
      }
  
      fclose($file);
  }
  </code></pre>