RE: Arrays from forms....

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

 



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.

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

Gary E. Terry wrote:
> I don't know if we are on the same page here... Maybe we are and I am just
> an idiot.
> 
> The fields in my db are image1 image2 and image3.
> 
> There are only three fields in the form that is being passed to the
> php script. But, on the form they are named "pictures[]".
> 
> Here is the full php I am using to process the form output:
> 
> <?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'];
> $status = $_POST['status'];
> 
> $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'>";
> ?>
> 
> 
> $image1 $image2 and $image3 are not getting defined... Not real sure
what's
> going on.

Always cc the list so others can learn or suggest things.

Are you uploading 3 images? Maybe define them first as well:

foreach ($_FILES .. ) {
   ${"image".$key} = "";

   if ($error == ....


or do you mean the values are always empty?

-- 
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