I have to receive a variable from URL (GET) and use it. It's just a number (from 0 to 400) and with that value I do a query.
To make sure no one is doing something wrong (SQL Injection or something else, I'm not an expert on security), I used: mysqli_real_escape_string() and also used an IF: if($id > 0 and $id < 400)
Do you think it's enough? the entire code is below. Thanks!
if($_SERVER["REQUEST_METHOD"] == "GET") {
      // id enviado desde GET
    $id = mysqli_real_escape_string($db,$_GET['id']); // $db es la conexión MySQL
    if($id > 0 and $id < 400) {   
        $sql = "SELECT url FROM urls WHERE id = '$id'"; // Traemos la primera URL del id correspondiente
        $result = mysqli_query($db,$sql); 
        echo "Cantidad de rows devueltas x la consulta SQL:" ;
        echo mysqli_num_rows($result);
        echo "<br>";
        while ($row = mysqli_fetch_array($result)) {
                echo $row[0];
                echo "<br>";
        }
    }
   }
 
    