title: No connection could be made using mysql_* API
body: <blockquote>
  <p><strong>Possible Duplicate:</strong><br />
  <a href="https://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a></p>
  </blockquote>
  
  <p>I tried to connect mysql database.but am getting the following error.</p>
  <blockquote>
  <p><strong>Warning:</strong> <code>mysql_connect()</code>: [2002] No connection could be made because the target machine actively (trying to connect via <code>tcp://localhost:3306</code>) in <code>test.php</code> on line <strong>5</strong></p>
  <p><strong>Warning</strong>: <code>mysql_connect():</code> No connection could be made because the target machine actively refused it. in test.php on line <strong>5</strong> Warning: <code>mysql_close()</code> expects parameter 1 to be resource, boolean given in <code>test.php</code> on line <strong>15</strong></p>
  </blockquote>
  <p><strong>test.php:</strong></p>
  <pre><code>&lt;?php
  $link = mysql_connect(localhost, dbuser, dbpass);
  if (!$link) {
     die('Could not connect: ' . mysql_error());
  }
  echo 'Connected successfully';
  mysql_close($link);
  ?&gt;
  </code></pre>