How do i insert this into my sql database? I have tried a few things like putting the array bracks on the upload file. when i do this it saves the image location but doesnt upload the image.
This is my upload snippet

for ($i=0;$i<4;$i++)
  {
   if($_FILES['userfile']['name'][$i])
   {
    $uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$i]);
    $ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
    if (preg_match("/(jpg|gif|png|bmp)/",$ext))
    {
     if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) 
     }

My insert snippet looks like this;

  $qry = "INSERT INTO properties(photourl,photourl2) VALUES('$userfile[1]','$userfile[0]')";
    $result = @mysql_query($qry);

    //Check whether the query was successful or not
    if($result) {
        header("location: register-success.php");
        exit();
    }else {
        die("Query WTF failed");
    }

as it is now i get no error , but the fields are empty .

What do you get if you echo $userfile[0] and $userfile[1]? Here I don't see how those variables are set.
Also remove @ from mysql_query and add or die(mysql_error()); at the end, so you can see what is wrong with your query.

when i echo that the lines are just empty...when i use.... $uploadfile[0] and $uploadfile[1] and putt the [] bracket on $uploadfile[] = $uploaddir . basename($_FILES['userfile']['name'][$i]);

i get the correct names but it stops uploading the images

THis is what i am saves the image name and location but stops actually uploading the image

for ($i=0;$i<4;$i++)
  {
   if($_FILES['userfile']['name'][$i])
   {
    $uploadfile[] = $uploaddir . basename($_FILES['userfile']['name'][$i]);
    $ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
    if (preg_match("/(jpg|gif|png|bmp)/",$ext))
    {
     if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) 
     }

INSERT QUERY

  $qry = "INSERT INTO properties(photourl,photourl2) VALUES('$uploadfile[1]','$uploadfile[0]')";
    $result = @mysql_query($qry);

    //Check whether the query was successful or not
    if($result) {
        header("location: register-success.php");
        exit();
    }else {
        die("Query WTF failed");
    }

it's ok i fixed it, just needed a seperate array to keep the values..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.