Hello, I am having problems with some code that I wrote. Basically I am trying to take image names that are uploaded in a directory and insert the names into a mysql database.. I have the following code:
------------start code-----------------
while($imgs[] = readdir($dir))
{
for($x=1;$x<count($imgs);$x++)
{
if($imgs[$x] != '.' && $imgs[$x] != '..')
{
$add = mysql_db_query($db, "INSERT INTO Images VALUES ( '', '$ID', '$imgs[$x]', '$uploaddt', '$expdt', '','','');");
}
}
}
The code will insert the picture names into the dbase but it "adds" more than one image name for each. In other words, if there are 3 images in the $dir it will add
3 names for the first image
2 names for the second image and 1 name for the third image instead of just adding one name for each.
Is there anybody who sees where I went wrong in the loop that is causing this problem?
Your help is greatly appreciated..