title: how to fix get_result and fetch_assoc with bind_result and fetch(wtithout getting Null)?
body: <p>i'm working on a project base on a tutorial, looks like my host can't fully support mysqlnd for using get_result. so after i've did some researches, i've found solution in using bind_result, after hours i've tried to fix it and still nothing.</p>
  
  <p>please help me to find the problem or change it in proper way.</p>
  
  <p>Here are the Codes base on Tutorial which they worked fine with XAMPP :</p>
  
  <p>Function.php</p>
  
  <pre><code>public function getUserInformation($phone)
  {
      $stmt = $this-&gt;conn-&gt;prepare("SELECT * FROM User WHERE Phone=?");
      $stmt-&gt;bind_param("s",$phone);
  
      if($stmt-&gt;execute()) {
          $user = $stmt-&gt;get_result()-&gt;fetch_assoc();
          $stmt-&gt;close();
  
          return $user;
      } else
          return NULL;
      }
  </code></pre>
  
  <p>And After I've changed them to this in function.php</p>
  
  <pre><code>public function getUserInformation($phone)
  {
      $stmt = $this-&gt;conn-&gt;prepare("SELECT Phone, Name, Birthdate, Address FROM User WHERE Phone=?");
      $stmt-&gt;bind_param("s",$phone);
  
      if($stmt-&gt;execute()) {
          $stmt-&gt;bind_result($phone, $name, $birthdate, $address);
          $user = array();
  
          while($stmt-&gt;fetch()) {
              $tmp = array();
              $tmp["phone"] = $phone;
              $tmp["name"] = $name;
              $tmp["birthdate"] = $birthdate;
              $tmp['address'] = $address;
              array_push($user, $tmp);
          }
  
  
          $stmt-&gt;close();
  
          return $user;
      } else
          return NULL;
      }
  </code></pre>
  
  <p>and now i'm getting</p>
  
  <pre><code>{"phone":null,
  "name":null,
  "birthdate":null,
  "address":null,
  "avatarUrl":null
  }
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>{"phone":"+18561523172",
  "name":"Johb",
  "birthdate":"1983-02-14",
  "address":"Nxy 123",
  "avatarUrl":""
  }
  </code></pre>
  
  <p>thanks.</p>
  
  <p>Edit 01.</p>
  
  <p>to answer the questions about error, this is the error :</p>
  
  <pre><code>&lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: Phone in &lt;b&gt;/home/meskand1/public_html/pasargad-    drinkshop/getuser.php&lt;/b&gt; on line &lt;b&gt;24&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: Name in &lt;b&gt;/home/meskand1/public_html/pasargad-    drinkshop/getuser.php&lt;/b&gt; on line &lt;b&gt;25&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: Birthdate in &lt;b&gt;/home/meskand1/public_html/pasargad-drinkshop/getuser.php&lt;/b&gt; on line &lt;b&gt;26&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: Address in &lt;b&gt;/home/meskand1/public_html/pasargad-drinkshop/getuser.php&lt;/b&gt; on line &lt;b&gt;27&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: avatarUrl in &lt;b&gt;/home/meskand1/public_html/pasargad-drinkshop/getuser.php&lt;/b&gt; on line &lt;b&gt;28&lt;/b&gt;&lt;br /&gt;
  {"phone":null,"name":null,"birthdate":null,"address":null,"avatarUrl":null}
  </code></pre>
  
  <p>before this with get_result i had issue with</p>
  
  <pre><code>Call to undefied method mysqli_stmt::get_result(
  </code></pre>
  
  <p>and the solution was to change it to bind_result and host don't care about mysqlnd problem</p>
  
  <p>omg After almost hours i've fixed it by changin to this :</p>
  
  <pre><code>public function getUserInformation($phone)
  {
      $stmt = $this-&gt;conn-&gt;prepare("SELECT Phone, Name, Birthdate, Address FROM user WHERE Phone=?");
      $stmt-&gt;bind_param("s",$phone);
  
      if($stmt-&gt;execute()) {
          $stmt-&gt;bind_result($arr['Phone'], $arr['Name'], $arr['Birthdate'], $arr['Address']);
          while ($stmt-&gt;fetch()) {
              $user[] = $arr;
          }
          $stmt-&gt;close();
  
          return $user;
      } else
          return NULL;
  }
  </code></pre>