Re: Arrays from forms....

From: Date: Fri, 01 Dec 2006 03:09:34 +0000
Subject: Re: Arrays from forms....
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-42782@lists.php.net to get a copy of this message
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/

« previous php.db (#42782) next »