Hello everyone i need some help with this code its a multiple file upload code max amount of files is 10 but it wont even upload one i just get the database info added about 500,000 times. Code is below
$query = mysql_query("INSERT INTO `listings` (state,name,location,price,typeofhome,bathrooms,bedrooms,basement,garage,features,remarks,lotsize,mlsid,hot) VALUES ('$status','$_POST[title]','$_POST[location]','$_POST[price]','$_POST[typeofhome]','$_POST[bathrooms]','$_POST[bedrooms]','$_POST[basment]','$_POST[garage]','$_POST[features]','$_POST[remarks]','$_POST[lot]','$_POST[mls]','$ishot')") or die("Failed because of ".mysql_error());
if ($query==TRUE) {
$id = mysql_insert_id();
$tmp = md5(rand());
$upload_dir = "pics/";
mysql_query("UPDATE `listings` SET `imgloco` = '$upload_dir' WHERE `id` = '$id'");
$num = $_POST['picnum'];
$i = 1;
while ($i>=$num) {
$file_tmp = $_FILES['pic'.$i]['tmp_name'];
$file_name = $_FILES['pic'.$i]['name'];
$loco = $upload_dir.$tmp;
move_uploaded_file($file_tmp,$loco);
mysql_query("INSERT INTO `list_images` (lid,location) VALUES ('$id','$loco')");
$i++;
}
redirect("templates/dellisting.php");
} else {
redirect("templates/addlisting.php");
}