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
Dynamic Array using glob?
Is there an easier way to do this?
I am trying to get create a dyamic array based on files wi
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
Call Screen statement Error
Dear Experts,
is there any setting that needs to be done before creating any dialog progr
echo $rows help
Hi all,
Hopefully something simple that I don't know!
I have this:
Code: [Selec
if else problem, help please
i have this script that i made only i try to also put in a if else for for some reason the script is
Losing 'page' data
I have this code that allows me to update my database. But after updating, I lose the $_GET['page']
How to convert this array to string
I am having problems converting this array to a string
using print_r($val[1]); I get:
Code: [
Comparing Values
Hi
I'm reading data from a database and this seems to work OK.
Each system has an associat
PHP Tab Control
Hi All,
I would like to have PHP tab control with/without Javascript.
But I want to r
help with multi-update
Now sure how to ask this really....
10g database if that matters.
I have a customer