title: Notice: Undefined variable: conn
body: <p>When I do my DB connection like this:</p>
  
  <pre><code>$conn = new MySQLi(RUBYDBUSER, RUBYDBNAME, RUBYDBPASS, RUBYDBDATA);
  if($conn-&gt;errno) {
      throw new Exception($conn-&gt;connect_error, $conn-&gt;connect_errno);
  }
  </code></pre>
  
  <p>and I want to run a prepared statement  like this:</p>
  
  <pre><code>public function getSitename() {
              $stmt = $conn-&gt;prepare("SELECT value FROM cms_options WHERE title = 'sitename' ");
              $db-&gt;stmt_init();
              $stmt-&gt;execute();
              $stmt-&gt;bind_result($sitename);
              if($stmt-&gt;num_rows &gt; 0) {
                  while ($stmt-&gt;fetch) {
                      return $sitename;
                  }
              }
          }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Notice: Undefined variable: conn in C:\xampp\htdocs\ruby\app\includes\classes\class.core.php on line 26</p>
  </blockquote>
  
  <p>The query is in <code>class.core.php</code> and the connection in <code>global.php</code>. The Class.core is included like this:</p>
  
  <p>(global.php)</p>
  
  <pre><code>foreach(glob(RUBY_BASE . '/app/includes/classes/class.*.php') as $class){
      include_once($class);
  }
  </code></pre>
  
  <p>Any answers?
  `</p>