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
delete comma
HI,
How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr
Using mysql_real_escape_string for displayed content
On my website users can input data into a textarea and it will store it in the mysql database. But,
2 things: enter doesn't work in IE & empty form
i have this search form that works well except for 2 things.
1) on IE when i hit enter instea
Appending GET data with form submition
Okay, what I'm trying to do is to use a form to append an already existing GET data string.
I
Class not found error
I am getting Class 'index' not found in Eval function:
//write config
$pat
FFmpeg Images 2 Video conversion problem ??
I got folder full of images , number of images = 600 , I want to make a video which plays one image
Async WSAConnect failed on XP with error code = 2 ("File not found")
Hi all,
I have very strange bug, please help me if you can.
It is reproduced o
PHP Code / Script To check weather the given email exists in a domain
Hi,
I want to implement the following in my web page
in sign up we will ask to enter u
array & querys help/advice.
Ok so here goes , I have a mysql database and basically here's what I need to do.
// foreach
Data type mismatch
Hi,
I am migrating data from algol to c.I mapped real datatype in algol to double datatype in