It did help and I altered the script a bit. It now reads as: $count = 0; //get file size function function fsize($file) { $a = array("B", "KB", "MB"); $pos = 0; $size = filesize($file); while ($size >= 1024) { $size /= 1024; $pos++; } return round($size,2)." ".$a[$pos]; } //loop through all the chosen file names and input them individually foreach ($filename as $filevalue){
$file_size = !fsize($filevalue); //get specific file name $parts=explode("\\",$filevalue); $file_name=$parts[sizeof($parts)]; //get file type extension $file_type = strrchr($filevalue,'.'); mssql_query ("INSERT INTO images (img_location, img_name, img_type, img_size, category_id)". "VALUES ('{$filevalue}', '{$file_name}', '{$file_type}', '{$file_size}', '{$catID}')"); $count++; //end of loop } Now I am receiving the error message of: Warning: Invalid argument supplied for foreach() in c:\inetpub\wwwroot\webpage10\example\u_images\act_load_imgs.php on line 43 Anyone have an idea of what may be causing this? thanks "Lars Torben Wilson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 2003-07-07 at 00:16, Micah Montoy wrote: > > I'm using the foreach to loop through a array that is passed from a form. > > The form has a multiple select field and the field sends a list of selected > > image locations (i.e. c:\\myimages\\rabbit.gif). All the fields are > > selected by use of JavaScript before the form is submitted. Anyway, I am > > getting the error: > > Hi there, > > > Parse error: parse error, unexpected T_FOREACH in > > c:\inetpub\wwwroot\webpage10\example\u_images\act_load_imgs.php on line 39 > > > > Here is the code that I am using. The foreach statement is line 39. > > > > //loop through all the chosen file names and input them individually > > $count = 0 > > You need a semicolon at the end of the above line. > > > foreach ($filename as $filevalue){ > > > > //get file size function > > function fsize($file) { > > $a = array("B", "KB", "MB"); > > $pos = 0; > > $size = filesize($file); > > while ($size >= 1024) { > > $size /= 1024; > > $pos++; > > } > > This function definition should not be inside the foreach(), since the > second time the loop executes, it will stop and tell you that you can't > redeclare an already defined function (and it was defined on the first > loop). > > I haven't checked the rest of it; try the above ideas and see if they > help. > > > Good luck, > > Torben > > > -- > Torben Wilson <[EMAIL PROTECTED]> +1.604.709.0506 > http://www.thebuttlesschaps.com http://www.inflatableeye.com > http://www.hybrid17.com http://www.themainonmain.com > -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====----- > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php