Selecting a record on a database with an Iterator
Posted: Wed Aug 20, 2008 5:55 am
Hi! I have a problem with selecting records on my table... apparently, it doesn't go to the next record... it only recognizes the first record. Is there anything wrong with my code?!
Any input will be greatly appreciated... thanks!
Code: Select all
<?php
set_time_limit(2500);
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("secuvir", $con);
mysql_query("DELETE FROM logs");
$result = mysql_query("SELECT * FROM v_list");
$drive1="C://";
ini_set('memory_limit', 32 * 1024 * 1024 * 1024* 1024);
if(file_exists($drive1)){
while($row = mysql_fetch_array($result))
{
$it = new RecursiveDirectoryIterator("$drive1");
foreach(new RecursiveIteratorIterator($it) as $file) {
$filename=basename($file);
if($filename==$row['Name']){
$time=date('h:i',time());
$date=date('Y-m-d');
$file2=addcslashes($file,"'\'");
mysql_query("INSERT INTO logs (id, Name, Path, Date_spot, Time_spot)
VALUES ('$suspicious', '$filename', '$file2','$date','$time')");
mysql_query("INSERT INTO logs_history (id, Name, Path, Date_spot, Time_spot)
VALUES ('$suspicious', '$filename', '$file2','$date','$time')");
echo "<font size=1 color=black>".$file."</font><font size=1 color=red>WARNING!</font><br/>";
}
else
{
echo "<font size=1 color=black>".$file."<br/>";
}
}
}
}mysql_close($con);
?>
<script language="javascript" type="text/javascript">
<!--
window.location="delete.php";
// -->
</script>