title: Undefined variable: pdo, call to a member function prepare() on null
body: <p>I was following a video and double checking all code and everything seems to be the same yet I get these errors.</p>
  
  <p><strong>Errors</strong>:</p>
  
  <p><em>Notice: Undefined variable: pdo in QueryBuilder.php on line 14</em></p>
  
  <p><em>Fatal error: Call to a member function prepare() on null in QueryBuilder.php on line 14</em></p>
  
  <p><strong>QueryBuilder.php</strong>:</p>
  
  <pre><code>class QueryBuilder
  {
      protected $pdo;
  
      public function __construct($pdo)
      {
          $this-&gt;pdo = $pdo;
      }
  
      public function selectAll($table)
      {
          $query = $pdo-&gt;prepare("SELECT * FROM `$table`"); // --&gt; LINE 14 &lt;--
          $query-&gt;execute();
          return $query-&gt;fetchAll();
      }
  }
  </code></pre>
  
  <p><strong>Connection.php</strong>:</p>
  
  <pre><code>class Connection
  {
      public static function make()
      {
          $servername = "localhost";
          $dbUsername = "root";
          $dbPassword = "";
          $dbName = "test";
  
          try {
              $pdo = new PDO("mysql:host=$servername;dbname=$dbName", $dbUsername, $dbPassword);
              $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              $pdo-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
              return $pdo;
          }
          catch(PDOException $e){
              die($e-&gt;getMessage());
          }
      }
  }
  </code></pre>
  
  <p><strong>init.php</strong>:</p>
  
  <pre><code>require "database/Connection.php";
  require "database/QueryBuilder.php";
  require "app/Product.php";
  
  $query = new QueryBuilder(Connection::make());
  </code></pre>