title: How to fix Upload image using php and mysqli
body: <p>I tried replacing mysql to mysqli, but I encountered an error in this code, it worked on mysql before. What is wrong?</p>
  
  <p>Php:</p>
  
  <pre><code>&lt;?php include "../../../_includes/config.php"; ?&gt;
  &lt;?php
  session_start();
  if(!empty($_FILES['userAvatar']['name'])){
    $uploadedFile = "";
    if(!empty($_FILES["userAvatar"]["type"])){
      $filename = $_FILES['userAvatar']['name'];
      $valid_extensions = array("jpeg", "jpg", "png");
      $temporary = explode(".", $_FILES["userAvatar"]["name"]);
      $file_extension = end($temporary);
      if((($_FILES["userAvatar"]["type"] == "image/png") || ($_FILES["userAvatar"]["type"] == "image/jpg") || ($_FILES["userAvatar"]["type"] == "image/jpeg")) &amp;&amp; in_array($file_extension, $valid_extensions)){
        $sourcePath = $_FILES['userAvatar']['tmp_name'];
        $targetPath = "../../../uploads/image/".$filename;
        if(move_uploaded_file($sourcePath, $targetPath)){
          $uploadedFile = $filename;
        }
      }
    }
    $display_name = $_POST['display_name'];
    $biography = $_POST['biography'];
    $sql = mysqli_query($connect, "UPDATE tb_users SET userDisplayName = '$display_name', userBiography = '$biography', userAvatar = '$uploadedFile' WHERE userLogin = '".$_SESSION['is_logged_in']['userLogin']."'") or die(mysqli_error());
    if($sql){
      echo "ok";
    }else{
      echo "err";
    }
  }else{
    echo "err";
  }
  ?&gt;
  </code></pre>
  
  <p>Result always "err".</p>