I can't figure out why my script is looping continuously. It checks to see if something is in the DB, if it IS present, it simply echo's 'Already Present'. However, if it ISN'T present it will input the data and then it SHOULD just exit because then there WILL be something in the DB. What am I missing? // Retrieve all data $query1 = mysql_query("SELECT * FROM table WHERE IP='$ip-address' AND DATE='$date'") or die(mysql_error()); // store the record into $row $row = mysql_fetch_array( $query1 ); // If no results, input new IP & DATE if(mysql_num_rows($query1)==0) { mysql_query("INSERT INTO downloads (IP, DATE, DOWNLOADED, EXEMPT) VALUES('$ip-address','$date','','0') ") or die(mysql_error()); } { echo 'Already present'; } PHP: