//connecting to MySQL database $conn = mysqli_connect("localhost", "username", "password", "database_name"); //query to check if title exists $query = "SELECT * FROM table_name WHERE title = 'Some title'"; //executing the query $result = mysqli_query($conn, $query); //checking if any rows were returned if(mysqli_num_rows($result) > 0){ echo "Title exists in database"; } else { echo "Title does not exist in database"; }
//path to text file $path = 'titles.txt'; //reading the file into an array $lines = file($path, FILE_IGNORE_NEW_LINES); //checking if title exists in the array if(in_array('Some title', $lines)){ echo "Title exists in file"; } else { echo "Title does not exist in file"; }Package library: None (uses built-in PHP functions)