title: Warning: mysql_query() [function.mysql-query]: Access denied for user ''@'localhost' (using password: NO)
body: <p>Good morning,
  I am running crazy trying one of the my first php codes with mysql. I have tested this on two servers, one hosted somewhere else and also using a local wamp server, the results are the same so I must have something bad in the code creating the connection or later when I run the query. </p>
  
  <p>For wamp I have already verified the php.ini and also the MySQL privileges, in the code I am using the credentials stated there. I would appreciate some guidance.</p>
  
  <pre><code> &lt;?php
  
   // Function: connect to a database. Returns the database connection.
  
  
  
  
    function connect_db($host, $id, $pwd)
    {
  
    $connection = @mysql_connect('localhost', 'username', 'password')
          or die('connection problem:' . mysql_error());
      mysql_select_db('database_db');
      return $connection;
      if (!$connection)
    {
      print ("internal error " . mysql_errno() );
    }
    }
  
   //get names from form
  
  $ID = $_POST['ID'];
  $Event= $_POST['Event'];
  $Date = $_POST['Date'];
  $Time = $_POST['Time'];
  $Venue= $_POST['Venue'];
  $TypeID= $_POST['TypeID'];
  $Score= $_POST['Score'];
  $Member = $_POST['Member'];
  
  //insert values
  $myquery = "INSERT INTO Results(ID, Event, Date, Time, Venue, TypeID, Score, Member )VALUES('$ID', '$Event', '$Date', '$Time', '$Venue', '$TypeID', '$Score', '$Member')";
  $answer = mysql_query($myquery);
  
  if (!$answer) {
      $message  = 'Invalid query: ' . mysql_error() . "\n";
      $message .= 'Whole query: ' . $myquery;
      die($message);
  }
  
  while ($row = mysql_fetch_assoc($answer)) {
      echo "Your results were entered successfully";
      echo "&lt;br&gt;";
      echo $row['Id'];
      echo $row['Event'];
      echo $row['Date'];
      echo $row['Time'];
      echo $row['Venue'];
      echo $row['TypeID'];
      echo $row['Score'];
      echo $row['Member'];
  }
  </code></pre>
  
  <p>?></p>