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
47
Other forums
session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.
FTP issues
Hi all,
I am currently facing some serious problems with a script and really need some ad
Had a simple form script that suddenly stopped working
It was made about a year ago and had been working fine. Last time it was known to work for sure was
Transaction variant for VA02 not working
My requirement is to have transaction for user to only add the output and print a sales order.
PHP error on MySQL insert
I'm sure it's the simplest of issues, but I can't recall why this isn't working.
Code: [Selec
How to read CSS message data
Hi,
I have a requirement here. When working as a Dev angel for multiple customers its really di
IP Logger for Voting Script
Can anybody help me place an IP logger into my voting script?
I know that maybe it is not as secu
error reporting
hey everyone
I have a production server in which I want error reporting but only on some page
Fetching array then reversing it
Hi, I have a simple problem, I'll try to explain it as best I can:
News entries in my database ar
Help: problem with Headers to download PDF file
Hi,
I'm trying to implement a script where when a user clicks a link he gets a PDF file to op