title: Mysqli Query result to variable
body: <p>I was trying to make a MySQL word with PHP, and I want to call the result into the next page using session. So I can put the result in the ms word file, but the value in <code>"$_SESSION['kode_faskes'] = $d['kode_faskes'];"</code> was stated as <code>null</code>.</p>
  
  <blockquote>
    <p>Notice: Trying to access array offset on the value of type null in C:\xampp\htdocs\test3\index.php on line 80</p>
  </blockquote>
  
  <p>this is the code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;?php include 'connection.php'; ?&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
    &lt;form action="index.php" method="get"&gt;
    &lt;label&gt; Cari :&lt;/label&gt;
    &lt;input type="text" name="cari"&gt;
    &lt;input type="submit" value="cari"&gt;
   &lt;/form&gt;
   &lt;?php
   //search norek 
   if(isset($_GET['cari']))
   {
    $cari = $_GET['cari'];
    echo "&lt;b&gt;Hasil Pencarian : ".$cari."&lt;/b&gt;";
   }
   ?&gt;
    &lt;table width="600" border="1"&gt;
     &lt;?php
     if(isset($_GET['cari']))
     {
      $cari = $_GET['cari'];
      $dato = mysqli_query($connect, "
  SELECT
   * 
  FROM
   faskes
   INNER JOIN pemilik_rekening USING ( norek )
   INNER JOIN transaksi USING ( kode_faskes )
  WHERE transaksi.norek LIKE
  '%".$cari."%'
  ");
     } else {
      $dato = mysqli_query($connect, "
  SELECT
   * 
  FROM
   faskes
   INNER JOIN pemilik_rekening USING ( norek )
   INNER JOIN transaksi USING ( kode_faskes )
   ");
     }
     $no = 1;
   while($d = mysqli_fetch_array($dato))
   {
     ?&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;?php echo $no++; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $d['kode_faskes']; ?&gt;&lt;/td&gt;
     &lt;td&gt;&lt;?php echo $d['nama_faskes']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $d['alamat_faskes']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $d['norek']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $d['pemegang_norek']; ?&gt;&lt;/td&gt;
     &lt;td&gt;&lt;?php echo $d['tanggal_bayar']; ?&gt;&lt;/td&gt;
     &lt;td&gt;&lt;?php echo $d['jumlah_bayar']; ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
   &lt;?php }   
     session_start();
     $_SESSION['cari'] = $cari;
     $_SESSION['kode_faskes'] = $d['kode_faskes'];
   ?&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If you can help me then I would be grateful for this.</p>
  
  <p>In addition, I'm deeply sorry about the short explanation.</p>