title: MySQL error on trying to open a MySQL connection
body: <p>I'm getting the following error when I try to open up a connection with MySQL running on my MACBOOK:</p>
  
  <p>Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/Eugene/Sites/website/includes/database.php on line 15 Warning: mysql_connect(): No such file or directory in /Users/Eugene/Sites/website/includes/database.php on line 15 Notice: Undefined variable: connection in /Users/Evgeny/Sites/website/includes/database.php on line 16 Database connection failed: No such file or directory</p>
  
  <p>My constants are:</p>
  
  <pre><code>defined('DB_SERVER') ? null : define("DB_SERVER", "localhost");
  defined('DB_USER') ? null : define("DB_USER", "eugene");
  defined('DB_PASS') ? null : define("DB_PASS", "password"); // no comments please :)
  defined('DB_NAME') ? null : define("DB_NAME", "maindb");
  </code></pre>
  
  <p>The way I try to connect is:</p>
  
  <pre><code>$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
  if(!$connection) // if no connection - die
  {
      die("Database connection failed: " . mysql_error());
  }
  else // if there is a connection, then go and select a database
  {
      $db_select = mysql_select_db(DB_NAME, $connection);
      if(!$db_select) // if no database selected - die
      {
          die("Database selection failed: " . mysql_error());
      }
  }
  </code></pre>
  
  <p>Please help,</p>
  
  <p>Thanks in advance.</p>