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
Need help urgant
why down my code ony return one item instead of all the items selected.
$arr = array($date,$
What's wrong with my code
sobbing for many days, still don't know why please Help. Why my page isn't posted correctly. In a
Better Method of a Member Cloud
I assume most people know how tag clouds work, where the tags most used are bigger and the least use
A little help in c#
i am doing a simple paint program using c# i want to draw with the mouse so i wrote the code of the
SAP Logon Failed
I tried to login to SAP through MMC.
When i click start and give password.
it
Effort Estimation Template for Steady State Support
Hi Everyone,
Is there any SAP provided template/format for system change and enhancements
insert PHP code into function
Hi,
I'm having problems when trying following:
I have:
Code: [Select]createBar("Do
Is it a good practice to store user info. in sessions?
I am making a user class for my script which stores all the user information in sessions. It takes u
how to query data from website using VC?
I want to query some datum from a website,so I need a program to read data from a .csv file, and ass
What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin