Actually spoke too soon...
If I have three browse fields(A, B, C) and B is left empty, then C also becomes empty.
I know it is because of the exit but if I omit exit then it will perform the query on the empty field.
Any ideas?
foreach ($_FILES as $key => $value)
{
// Set variables
$fileName = $value[name];
$fileType = $value[type];
$fileSize = $value[size];
$fileError = $value[error];
// error checking
if ($fileError > 0)
{
echo 'Problem: ';
switch ($fileError)
{
case 1: echo 'File exceeded upload_max_filesize';
break;
case 2: echo 'File exceeded max_file_size';
break;
case 3: echo 'File only partially uploaded';
break;
case 4: echo 'No file uploaded';
break;
}
exit;
} // end error checking
// read file contents
$fp = fopen($value[tmp_name], 'rb');
$content = fread($fp, $fileSize);
$content = addslashes($content);
fclose($fp);
$tables = array(
"mergers" => "mergers",
"spin_offs" => "spin_offs",
"rights" => "rights",
"splits" => "splits");
$table = $tables[$key];
$query = "INSERT INTO $table (name, size, type, content, file_date) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content', NOW())";
$result = mysql_query($query) or die(mysql_error());
} // end foreach clause