RE: Arrays from forms....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If I print them, there's nothing. all three

Here is the same file, in test mode... 

<?php
include "db.inc.back.php";


foreach ($_FILES["pictures"]["error"] as $key => $error) {
   if ($error == UPLOAD_ERR_OK) {
       echo "$error_codes[$error]";
       move_uploaded_file(
         $_FILES["pictures"]["tmp_name"][$key],
         "bikeimages/" .$_FILES["pictures"]["name"][$key]
       ) or die("Problems with upload");
       ${"image".$key} = $_FILES['pictures']['name'];
   }
}

$make = $_POST['make'];
$model = $_POST['model'];
$year = $_POST['year'];
$color = $_POST['color'];
$description = $_POST['description'];
//$image1 = $_POST['image1'];
//$image2 = $_POST['image2'];
//$image3 = $_POST['image3'];
$status = $_POST['status'];

echo "$image1 -- $image2 -- $image3";
/*
$query = "INSERT INTO `inventory` (`make`, `model`, `year`, `color`,
`description`, `image1`, `image2`, `image3`, `status`)
            VALUES ('$make', '$model', '$year', '$color', '$description',
'$image1', '$image2', '$image3', '$status');";

$result = mysql_db_query("$db", $query) or displayErrorQuery ($query);

echo "<meta http-equiv='refresh' content='0;URL=inventorylist.php'>";
exit;
*/
?>

 I get " -- -- " outputted.

-----Original Message-----
From: Chris [mailto:dmagick@xxxxxxxxx] 
Sent: Thursday, November 30, 2006 10:39 PM
To: Gary E. Terry
Cc: php-db@xxxxxxxxxxxxx
Subject: Re:  Arrays from forms....

Gary E. Terry wrote:
> Sorry about that, not CC'ing the list...
> 
> the values are not always empty, they should always have something in
> them...  
> 
> There should be 3 images uploading. But, I am sure just to make life
> interesting,
> there will be times when there could be as little as one uploaded.

If you print them out what's in them?

echo $image1;
echo $image2;

I just realized that the $key probably starts at 0 instead of 1, so you 
might need to check that and then possibly:

${"image".($key+1)} = $_FILES['pictures']['name'];

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux