error on array loop through foreach?
| From: | Micah Montoy | Date: | Mon, 07 Jul 2003 07:16:42 +0000 |
| Subject: | error on array loop through foreach? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-154158@lists.php.net to get a copy of this message | ||
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:
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
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++;
}
return round($size,2)." ".$a[$pos];
}
$file_size = !fsize($filevalue);
//get specific file name
$parts=explode("\\",$filevalue);
$file_name=$parts[sizeof($parts)];
//get file type function
$ext = strrchr($file_loc_name,'.');
$file_type = $ext;
//write information from file to db
$sql = "INSERT INTO images "
. "(img_location, img_name, img_type, img_size, category_id) ";
$sql.= "VALUES (";
$sql.= "'{$filevalue}', '{$file_name}', '{$file_type}',
'{$file_size}',
'{$catID}')";
mssql_query ($sql);
$count++;
//end of loop
;}
Anyone see what may be causing this? When I do a simple foreach ($filename
as $filevalue){ echo ($filevalue);}, it will return all the files names
chosen from the form.
thanks