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 with basic sql
Hi,
I am using oracle 10g, and having some small doubts related to sql , here goes the si
Logic question
im wondering what's the best method to do the above list:
it is for alliance @ MMORPG game
MySQL-PHP Query Results Help
Hello all. I'm hoping to be able to get some help in solving a problem with query/rowcount output. I
How to sum these output values
Hi
I need sum the month totals
SELECT region_name, area_name
,SUM (CASE WHEN S
Unable to retreve the values from Mysql Query
Hi,
Here is the php code that I have, Query is running properly in phpmyadmin and is resu
Javascript using window.location seems to lose state
Not sure what forum so let me know if I'm in the wrong place.
I have a main window with a ajax grid
Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.
We made a reverse goods movemen
LSB (PHP 5.3) problem with static value!
hello,
i'm having a problem. static::$text variable gets lost at some point. can someone plea
Chat Box in PHP
I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Mes
Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s