title: establishing a database connection
body: <p>My database is named 'login'. This is the php statement that is used in my login.php/register.php files (saved to htdocs)which is supposed to establish a database connection.</p>
  
  <pre><code>$this-&gt;db_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  </code></pre>
  
  <p>I want to make sure I connect successfully so i assume I have to change these</p>
  
  <pre><code>(DB_HOST, DB_USER, DB_PASS, DB_NAME)
  </code></pre>
  
  <p>to this</p>
  
  <pre><code>('localhost', 'username', 'password', 'login');
  </code></pre>
  
  <p>The only problem is i get thrown off with the naming conventions  i.e. 'localhost', 'root', 'root', etc . This is what's listed on my mamp start up page</p>
  
  <pre><code>Host    localhost
  Port    3306
  User    root
  Password    root
  Socket  /Applications/MAMP/tmp/mysql/mysql.sock
  </code></pre>
  
  <p>These are the examples listed on my mamp start up page for using the info</p>
  
  <pre><code>$user = 'root';
  $password = 'root';
  $db = 'inventory'; //what is this?
  $host = 'localhost';
  $port = 3306;
  
  $link = mysql_connect(
  "$host:$port", 
  $user, 
  $password
  );
  $db_selected = mysql_select_db(
  $db, 
  $link
  );
  </code></pre>
  
  <p>does this mean i should configure login/register.php to;</p>
  
  <pre><code>$this-&gt;db_connection = new mysqli  ('localhost', 'username', 'password', 'login');
  </code></pre>
  
  <p>or is it done this way?</p>
  
  <pre><code>$this-&gt;db_connection = new mysqli  ('localhost', 'root', 'root', 'login');
  </code></pre>
  
  <p>This was in the configuration file db.php which is supposed to be saved in the same directory for my application;</p>
  
  <pre><code>&lt;?php
  
  define("DB_HOST", "127.0.0.1");
  define("DB_NAME", "login");
  define("DB_USER", "root");
  define("DB_PASS", "mysql");
  ?&gt;
  </code></pre>
  
  <p>I thought that </p>
  
  <pre><code>'DB_HOST',
  'DB_NAME',
  'DB_USER',
  'DB_PASS' 
  </code></pre>
  
  <p>were space fillers meant to be edited and changed but does this mean i can keep the original line;</p>
  
  <pre><code>$this-&gt;db_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  </code></pre>
  
  <p>If i save db.php in the same directory? Or again, could i or should i edit it to read something like;</p>
  
  <pre><code>define("DB_HOST", "127.0.0.1"); **** define("DB_HOST", "localhost");
  define("DB_NAME", "login");     **** define("DB_NAME", "login");
  define("DB_USER", "root");      **** define("DB_USER", "root");
  define("DB_PASS", "mysql");     **** define("DB_PASS", "root"); //i.e. my password has never been mysql
  </code></pre>
  
  <p>I was also wondering if this line would act as a reliable constant;</p>
  
  <pre><code>grant all privileges on login.* to 'root'@'localhost' identified by 'root'; //or should it be identified by 'password'?
  </code></pre>