title: trouble with constants and connecting to database PHP
body: <p>I'm getting these errors in my on screen </p>
  
  <blockquote>
    <p>Notice: Use of undefined constant DB_SERVER - assumed 'DB_SERVER' in
    C:\xampp\htdocs\photo_gallery\includes\database.php on line 13</p>
    
    <p>Notice: Use of undefined constant DB_USER - assumed 'DB_USER' in
    C:\xampp\htdocs\photo_gallery\includes\database.php on line 13</p>
    
    <p>Notice: Use of undefined constant DB_PASS - assumed 'DB_PASS' in
    C:\xampp\htdocs\photo_gallery\includes\database.php on line 13</p>
    
    <p>Warning: mysql_connect(): php_network_getaddresses: getaddrinfo
    failed: No such host is known. in
    C:\xampp\htdocs\photo_gallery\includes\database.php on line 13</p>
    
    <p>Warning: mysql_connect(): php_network_getaddresses: getaddrinfo
    failed: No such host is known. in
    C:\xampp\htdocs\photo_gallery\includes\database.php on line 13
    Database connection failed: php_network_getaddresses: getaddrinfo failed: No such host is known.</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  require_once("config.php");
  
  class MySQLDatabase {
  
      private $connection;
  
    function __construct() {
      $this-&gt;open_connection();
    }
  
      public function open_connection() {
          $this-&gt;connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
          if (!$this-&gt;connection) {
              die("Database connection failed: " . mysql_error());
          } else {
              $db_select = mysql_select_db(DB_NAME, $this-&gt;connection);
              if (!$db_select) {
                  die("Database selection failed: " . mysql_error());
              }
          }
      }
  </code></pre>
  
  <p>My constants are defined as so:</p>
  
  <pre><code>&lt;?php
  
  // Database Constants
  defined('DB_SERVER') ? null : define("DB_SERVER", "localhost");
  defined('DB_USER')   ? null : define("DB_USER", "gallery");
  defined('DB_PASS')   ? null : define("DB_PASS", "phpOTL123");
  defined('DB_NAME')   ? null : define("DB_NAME", "photo_gallery");
  
  ?&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>