Problems with array


Posted on 16th Feb 2014 07:03 pm by admin

This code is the last lines in an upload script that uploads 4 images at the same time and writes the url to these and som other information to the database.
database structure: id img1 img2 img3 img4 imageobject imageinfo imagecategory

The problem is that im trying to write an array on $destination so i can insert the urls as below: IMG1= $destination[1] and so on. the example below writes the same url four times insted of every files url one time.

imagedestroy($src);
imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request
// has completed.

echo "Successfully Uploaded: ".$filename."
";
}

if(isset($_POST[submit])){
$imgNumb=1; //This the "pointer" to images
$DestinationDir="images/gallery/"; //Place the destination dir here


while ($_FILES["img".$imgNumb][tmp_name]){
$Unique=microtime(); // unique names
$destination=$DestinationDir.md5($Unique).".jpg";
imgReisize($_FILES["img".$imgNumb][tmp_name], $destination);
$imgNumb++;


}

$destination = array(1 => $destination, 2 => $destination, 3 => $destination, 4 => $destination);

include("includes/connect_database.php");


$sql = mysql_query("INSERT INTO test (img1, img2, img3, img4, imageobject, imageinfo, imagecategory) values ('$destination[1]', '$destination[2]', '$destination[3]', '$destination[4]', '$_POST[imageobject]','$_POST[imageinfo]','$_POST[imagecategory]')");
mysql_close()

No comments posted yet

Your Answer:

Login to answer
273 Like 47 Dislike
Previous forums Next forums
Other forums

extract a file from zip file
hi,
i know how to unzip a zip file in php, but is there a way to just extract a certain file only

Error in Configure System Landscape Directory phase
Hi

We are getting the error in Configure SLD phase ( 41 of 44 phase).

Please f

Local file browser with php
Halo..

So this is what i want to create. I have a folder that i share and it has many movies.

PHP SUBMIT
Code: <input name="doLogin" type="image" src="images/loginsubmit.jpg

Java API in PHP?
I have an application that we use internally here at the office.

The software company provide

Random Number Generation And Probability
Hello, I am working on a function which has to insert data into a SQL table.

we have to suppl

check if string contain only a-z/A-Z
Is where any way to check if string contains only a-z/A-Z, without writing an array with all possibl

php slowing my site?
Hi all,

I think that one of the reasons that my site doesn't work fast is that the code is ve

Printing a webpage
I use this to print the webpage: o

Convert array to string and write to csv file
I am looking to write a MySQL query to a csv file.

At the minute I:

check for the orig

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash