PHP Code:
$userIP $_SERVER["REMOTE_ADDR"];  
//$userIP = filter_var( $userIP, FILTER_VALIDATE_IP );
$mydb = @ new mysqli('localhost','root','','questiondb');
if (
mysqli_connect_errno()) {
    echo 
"Conection error:".mysqli_connect_error();
    exit();
 }
 
 
$userIP $mydb->real_escape_string($userIP);
 
$mydb->query("INSERT INTO ipt (ip) VALUES ('$userIP')");
  
 
 
$result_set  $mydb->query('SELECT ip FROM ipt');
 
    while(
$row $result_set->fetch_assoc()) {
    
print_r($row); 
    echo
"<br />";
        }
 
 
$result_set->close();
 
$mydb->close(); 
Everything works now . Here is the final code . Data goes in and out . Thank you people . This was very helpful!