Data is not uploaded on database and yet the image is uploaded and the rename of the file does not occur. I am very new to PHP and any help is appreciated.
$hash is md5() hash of image
$j is hash(hash(image).date)
$newfile = $hash.".".$file_extension;
$l2 is link address.
   if (file_exists($final_dir))
    {
        $newfile =  $j.'.'.$file_ext; //This will rename file with current time stamp which will always unique.
        $l2="$l"."$newfile";
        $hash = $j;
    }
    $upload = move_uploaded_file($filetmp,$final_dir);              //uploading the file to the server
      $select_query = "INSERT   INTO image_table(i_name,i_location,i_hash,image_url) VALUES('$newfile','$final_dir','$hash','$l2')"; // Database query 
            $selected = mysqli_query($connect,$select_query);
