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.
Did you know?Explore Trending and Topic pages for more stories like this.
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
47
Other forums
Google voice
I currently have a form in html, but I want it in php so the information is not in the source code.<
PHP Thumbnail Creation
Ok so i use this function to create thumbnails:
Code: [Select]function createthumb($name,$fil
Remove directories not empty
hi,
i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder.<
Text to picture Generator
Hello, i have found this script and it works really good^^ But i have one problem, i would like to c
Upload, SSL and more php help
I recently just installed a ssl cert and do i use https for the whole site or just for the checkout.
VAT
how should I deal with VAT?
if I have a product that costs £5.00 and VAT @ 17.5% (£0.87
PHP hyperlinks generator
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500
Hi, explode and strstr.
Hi, I seem to be confused about the strstr function, eg. i have a string like:
"a.b.c.d.e.f&
SOAP Issue
Hi,
I am facing some understanding problem with SOAP basic.kindly recommend some SOAP expert.
multipart emiail forms
Hi All,
I am new to the boards and I've been working on a form (which is rather massive, imo