What are the potential security risks of passing SQL code through a URL in PHP?

Passing SQL code through a URL in PHP can lead to SQL injection attacks, where malicious SQL code is inserted into the URL to manipulate the database. To prevent this, it is important to sanitize and validate user input before using it in SQL queries.

// Sanitize and validate input before using it in SQL queries
$input = $_GET['input'];
$safe_input = mysqli_real_escape_string($connection, $input);

$sql = "SELECT * FROM table WHERE column = '$safe_input'";
$result = mysqli_query($connection, $sql);

// Rest of the code to process the query result