title: Fetch only one field in php and mysqli
body: <p>I have the following code </p>
  
  <pre><code>if (isset($_POST['change'])) {
      $current = mysqli_real_escape_string($con, $_POST['current']);
      $password = mysqli_real_escape_string($con, $_POST['password']);
      $cpassword = mysqli_real_escape_string($con, $_POST['cpassword']);
  
      if(strlen($password) &lt; 6) {
          $error = true;
          $password_error = "Password must be minimum of 6 characters";
      }
      if($password != $cpassword) {
          $error = true;
          $cpassword_error = "Password and Confirm Password doesn't match";
      }
  
      if(mysqli_fetch_field(mysqli_query($con, "SELECT password FROM users WHERE id = '" . $_SESSION['usr_id'] . "' LIMIT 1")) != md5($current)) {
          $error = true;
          $confirm_error = "Your actual password is not correct";
      }
  }
  </code></pre>
  
  <p>The problem is here:</p>
  
  <pre><code>mysqli_fetch_field(mysqli_query($con, "SELECT password FROM users WHERE id = '" . $_SESSION['usr_id'] . "' LIMIT 1"))
  </code></pre>
  
  <p>It gives me the error </p>
  
  <blockquote>
    <p>PHP Catchable fatal error:  Object of class stdClass could not be converted to string in /.../password.php on line 27</p>
  </blockquote>
  
  <p>I have tried with </p>
  
  <p><code>mysql_result(mysqli_query($con, "SELECT password FROM users WHERE id = '" . $_SESSION['usr_id'] . "' LIMIT 1"), 0)</code></p>
  
  <p>but it not works, it gives me </p>
  
  <blockquote>
    <p>PHP Fatal error:  Uncaught Error: Call to undefined function mysql_result() in /.../password.php:27</p>
  </blockquote>
  
  <p>I don't want to use <code>mysqli_fetch_array()</code> and a <code>while</code> loop. I have searched for a function or something similar and i have found something but nothing worked for me.</p>