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
first id from db not showing
I have a php script which displays the content of a mysql table as a html table with sorting, delete
Update Database
Hi All,
I have a problem with this:
Code: [Select]<?php
session_start();
Send inserts to mysql thru port 80
Hi!
I have an application that must do some inserts in a mysql db. This db is behind a firewa
Vertical Alligning - Not working in 1 cell?
<?php
echo "<table id="valign" width="60%" style=
please help me... my password gets encrypted but not able to get in database
hai guys,
please help me... in the following function my password gets encrypted but no
search function
HI guys,
if anyone could point us in the right direction of how to do this, or provide some t
Grabbing Values From an Array for Posting
I have a grid array that I am using with a form that when it hits the currently named test.php it lo
Add User script "Could not execute query"
This should be an easy script but I can't get it to run. Can someone please help me?
<
Simple MySQL script is not working
Hey guys,
Just familiarizing myself with PHP and MySQL. I am following along in the O'Reilly
Checking if field is empty AND using !is_numeric
Hi lads,
Need to be able to display an error message (using isset?) that says "Cant lea