title: mysql_query() Access denied for user
body: <p>I'm making a PHP and MySQL RPG game, and my changeEquipment page is not working. I'm getting these errors:</p>
  
  <blockquote>
    <p>Warning: mysql_query() [function.mysql-query]: Access denied for user
    'devinfa1'@'localhost' (using password: NO) in
    /home/devinfa1/public_html/spellsword/changeEquipment.php on line 21</p>
    
    <p>Warning: mysql_query() [function.mysql-query]: A link to the server
    could not be established in
    /home/devinfa1/public_html/spellsword/changeEquipment.php on line 21</p>
    
    <p>Warning: mysql_query() [function.mysql-query]: Access denied for user
    'devinfa1'@'localhost' (using password: NO) in
    /home/devinfa1/public_html/spellsword/changeEquipment.php on line 27</p>
    
    <p>Warning: mysql_query() [function.mysql-query]: A link to the server
    could not be established in
    /home/devinfa1/public_html/spellsword/changeEquipment.php on line 27</p>
  </blockquote>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  // Get commonFunctions.php
  require_once('commonFunctions.php');
  
  // Start the session and connect to the database
  session_start();
  $con = mysql_connect("localhost","devinfa1_user","dbpass");
  if (!$con) { die('Could not connect: ' . mysql_error()); }
  mysql_select_db("devinfa1_spellsword", $con);   
  
  // If logged in
  if(isset($_SESSION['account_name'])) {
      // If form is submitted
      if(isset($_POST['submit']) || isset($_POST['submit_x'])) {
  
          // If the hero has more than one weapon
          if(hero_has_multiple_weapons()) {
              // Set new weapon
              mysql_query("UPDATE Hero_Weapons SET active_weapon = TRUE WHERE HW_hero_id =
                  (SELECT hero_id FROM Heroes WHERE hero_name = '$_SESSION[hero_name]')
                  AND HW_item_id = (SELECT item_id FROM Items WHERE item_name = '$_POST[weapon]')");
  
              // Unset previous weapon
              if(isset($_SESSION['hero_name'])) {
                  mysql_query("UPDATE Hero_Weapons SET active_weapon = FALSE WHERE HW_hero_id =
                      (SELECT hero_id FROM Heroes WHERE hero_name = '$_SESSION[hero_name]')
                      AND HW_item_id = (SELECT item_id FROM Items WHERE item_name = '$_SESSION[weapon_name]')");
              }
          }
  
  // Close the database connection
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>So, the PHP should be connecting to my databse using the <code>devinfa1_user</code> username and <code>dbpass</code> password, but it's apparently trying to use the <code>devinfa1</code> username with no password.</p>
  
  <p>I have no idea why this is the case, because I have the exact same connection code and an update statement on my changeHero page and it works perfectly. Any ideas?</p>