title: Using PHP CONSTANTS in PDO calls
body: <pre><code>&lt;?php # Nettuts Tutorial using PHP Data Objects (PDO),
  
  /**This file contains the database access information
   *This file also establishes a connection to mySQL
   *and selects the database.
   *Set the database access information as constants:
   **/
  // print_r(PDO::getAvailableDrivers());
  
  DEFINE('DB_USER', 'root');
  DEFINE('DB_PASSWORD', 'root');
  DEFINE('DB_HOST', 'localhost');
  DEFINE('DB_NAME', 'sitename');
  
  $php = "htmlspecialchars";
  try {
      #MySQL with PDO_MYSQL
      // $DBH = new PDO("mysql:host={$php(DB_HOST)}; dbname={$php(DB_NAME)}", root, root};  
      $DBH = new PDO("mysql:host=localhost; dbname= sitename", root, root);
  
      $DBH-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      # UH-OH! Typed DELECT instead of SELECT!
      $DBH-&gt;prepare('DELECT name FROM people');
  } catch (PDOException $e) {
      echo "I'm sorry, Dave. I'm afraid I can't do that.";
      file_put_contents('PDOErrors.txt', $e-&gt;getMessage(), FILE_APPEND);
  }
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>The Console in OS X returns "[14-Aug-2011 15:59:59] PHP Notice:  Use
    of undefined constant root - assumed 'root' in
    /Applications/MAMP/htdocs3/nettuts/PHP/PDO for Database
    Access/mysql_pdo_connect.php on line 20."</p>
  </blockquote>
  
  <p>I've "googled" and found a partial answer here. So I was hoping for completion here.</p>
  
  <p>TIA</p>