title: Connecting to mysql using php
body: <p>Here is my following tutorial code from "Learning PHP MYSQL and Javascript" by OReilly. </p>
  
  <pre><code>&lt;?php 
  //require_once = 'login.php';
  
  $db_database = 'publications';
  $db_hostname = 'localhost:8888';
  $db_username = 'root';
  $db_password = 'root';
  
  
  $db_server = mysql_connect($db_hostname, $db_username, $db_password);
  if(!$db_server) die("Unable to connect to MYSQL: ". mysql_error());
  
  mysql_select_db($db_database)
      or die("Unable to connect to database: " . mysql_error());
  
  $query = "SELECT * FROM classics";
  $result = $mysql_query($query);
  
  if(!$result) die ("Could not query: " . mysql_error());
  $rows = mysql_num_rows($result);
  
  for($j = 0; $j &lt; $rows; ++$j)
  {
      echo 'Author: ' . mysql_result($result, $j, 'author') . '&lt;/br&gt;';
      echo 'Title: ' . mysql_result($result, $j, 'title'). '&lt;/br&gt;';
      echo 'ISBN: '.mysql_result($result, $j, 'isbn').'&lt;/br&gt;';
  }
  
  ?&gt;
  </code></pre>
  
  <p>However, I'm getting an error when trying to connect. The browser says it's a 500 error (which really isn't that helpful). When I take out the lines <code>$db_username = 'root'; $db_password = 'root';</code> I get another error saying: "Unable to connect to database: Access denied for user ''@'localhost' to database 'publications'".</p>
  
  <p>Can anyone help diagnose the problem?</p>
  
  <p>Thanks!</p>