title: error Call to a member function get_results()
body: <p>error:</p>
  
  <blockquote>
    <p>Call to a member function
    get_results() on null in C:\xampp\htdocs\shop\wp-content\plugins\myplugin\viwe.php:9 Stack trace: #0 {main} thrown in C:\xampp\htdocs\shop\wp-content\plugins\myplugin\viwe.php on line</p>
  </blockquote>
  
  <p>the code </p>
  
  <pre><code>global $wpdb;
  
  $query = $wpdb-&gt;get_results('SELECT * FROM test');
  </code></pre>
  
  <p>The folder myplugin contains the following two files,</p>
  
  <pre><code>index.php
  
  viwe.php
  </code></pre>
  
  <p>For file viwe.php, the code is not working and fails with,</p>
  
  <blockquote>
    <p>error
    Call to a member function
    get_results() on null in C:\xampp\htdocs\shop\wp-content\plugins\myplugin\viwe.php:9 Stack trace: #0 {main} thrown in C:\xampp\htdocs\shop\wp-content\plugins\myplugin\viwe.php on line</p>
  </blockquote>
  
  <p>But the index.php is working.</p>