0

I have:

$con = mysql_connect($db_server,$db_username,$db_password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db($db_db, $con);
  mysql_query("INSERT INTO failed_logins SET username = 'pachonk', ip_address = INET_ATON('$ip'), attempted = CURRENT_TIMESTAMP");
 // mysql_close($con);
echo $ip;

$count = get_attempts(); // Get the Number of Attempts
mysql_close($con);
sleep((2 ^ intval($count)) - 1);

function get_attempts(){
    $result = mysql_query("SELECT * FROM failed_logins WHERE ip_address = INET_ATON('$ip')");
    if(mysql_num_rows($result) > 0)
    {
        $num_rows = mysql_num_rows($result);
        return $num_rows;
    }
    else
    {
    echo NO;
        return 0;
    }
}

And when I run the second query on my SQL server, it runs just how I want it to, however I get 0 lines when I query via php. If I query for "username = pachonk", It's perfect how I want though as well. What's going on?

user1973551
  • 29
  • 1
  • 8

2 Answers2

0

If $ip is not empty(in your example $ip is empty) you can try to modify your function get_attempts() in get_attempts($ip);

Marius Darila
  • 873
  • 9
  • 13
0

your insert query should more or less look like this:

mysql_query("INSERT INTO failed_logins values('pachonk', INET_ATON('$ip'), CURRENT_TIMESTAMP");

then your select will give you some result

emfi
  • 649
  • 6
  • 23