$mysqli = new mysqli("localhost", "username", "password", "database"); $name = mysqli_real_escape_string($mysqli, $_POST['name']); $query = "INSERT INTO users (name) VALUES ('$name')"; mysqli_query($mysqli, $query);
$mysqli = new mysqli("localhost", "username", "password", "database"); $searchTerm = mysqli_real_escape_string($mysqli, $_GET['searchTerm']); $query = "SELECT * FROM products WHERE name LIKE '%$searchTerm%'"; $result = mysqli_query($mysqli, $query);In this example, we again create a new mysqli object and connect to the database. Then, we use the mysqli_real_escape_string function to escape the search term input from a GET request. Finally, we use the escaped search term in an SQL query to search for products with names matching the search term. The PHP mysqli_real_escape_string function is part of the mysqli package library, which is an extension of the PHP MySQL library.