title: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user
body: <p><strong>Html Form Submitted from</strong></p>
  
  <pre><code>&lt;?php
  ////////////////////////////////////////////////////////////////////////////////////
  ###### Require Database ######                              ////////////////////////
  require_once('src/cfg/dbi.php');
  
  ////////////////////////////////////////////////////////////////////////////////////
  ###### Call Session Functions Include ######                ////////////////////////            
  require_once('src/cfg/sess_function.php');                  ////////////////////////
  ###### Call function as contained in sess_function() ######                       //
  session_set_save_handler('_open','_close','_read','_write','_destroy','_clean');  //                            
  ###### Start session ###### ////////////////////////////////////////////////////////
  session_start(); ///////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////
  
  
  
  #fullname, email, password
      // Verify input was even provided
  if (isset($_POST['fullname']) &amp;&amp; isset($_POST['email']) &amp;&amp; isset($_POST['password'])) {
      // Clean Input
      $userName = mysql_real_escape_string($_POST['fullname']); 
      $userEmailAddress = mysql_real_escape_string($_POST['email']); 
      $userPassword = mysql_real_escape_string($_POST['password']);
  
      # hash cleaned pass...
      $dynamSalt = mt_rand(20,9999); 
      $userPassword = hash('sha512',$dynamSalt.$userPassword);
  
      # connect database, then prepare, and finally perform query…
      #require_once('src/cfg/dbi.php');
      try{
          $dbh = new PDO("mysql:host=$host;dbname=$dbname",$user,$pass);
          $dbh-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
          // INSERT CLEAN DATA INTO TABLE…
          $sth = $dbh-&gt;prepare("
          INSERT INTO Fan(fanNm,fanEmail,fanPass,fanDynamSalt)
          VALUES('$userName','$userEmailAddress','$userPassword','$dynamSalt')"
          );
          $sth-&gt;execute();
          ////////////////////////////////////////////////////////////////////
          ## Set Session Var for this PK ID in Fan table that is being created ##
          ////////////////////////////////////////////////////////////////////
          $_SESSION['newUserSessID'] = $dbh-&gt;lastInsertId();
  
      } //try
  
      catch(PDOException $e){
              #echo "Oops, We're experiencing an error.INSERTING NEW FAN";
              file_put_contents('/PDODBConnectionErrors.txt', $e-&gt;getMessage(), FILE_APPEND);  
      } //catch
  
  }
  else{
      // Redirect back to login form
      header('../index.php');
      //*SHOW ERRORS*// 
  
  }   
  </code></pre>
  
  <p><strong>The file dbi.php:</strong></p>
  
  <pre><code>&lt;?php
  ####### DB Config Setting #######
  $host ='localhost'; //////////////
  $dbname ='thedatabasesnamehere';//////////
  $user ='theuser';      //////////////
  $pass ='thepass';          //////////////
  /////////////////////////////////
  ?&gt;
  </code></pre>
  
  <p><strong>session_function.php</strong> - contains 6 sessions functions</p>
  
  <pre><code>    &lt;?php
      function _open()
      {
          try{
              // Open the database
              global $dbname, $host,$user,$pass;
              $dbh = new PDO("mysql:host=$host;dbname=$dbname",$user,$pass);
              $dbh-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
              #echo "&lt;DIV STYLE='COLOR:RED;'&gt;"."CONNECTED!!"."&lt;/DIV&gt;";
          } //try
          catch(PDOException $e){
              #echo "Oops, We're experiencing an error CONNECTING.";
              file_put_contents('PDODBConnectionErrors.txt', $e-&gt;getMessage(), FILE_APPEND);  
          } //catch
      }   
  
      ## Kill Connection to Mysql (Using PDO) 
      function _close(){
      $dbh = null;
      }
  
      ## Read a current session 
      function _read($id){
          try{
              // Open the database
              global $dbname,$host,$user,$pass;
              $dbh = new PDO("mysql:host=$host;dbname=$dbname",$user,$pass);
              $dbh-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
              // Begin Query
              $id = mysql_real_escape_string($id);
              $sth = $dbh-&gt;prepare("SELECT data FROM sessions WHERE id = '$id'");
              $sth-&gt;execute();
  
          }
          catch(PDOException $e){
              #echo "Oops, We're experiencing an error. READING";
              file_put_contents('PDODBConnectionErrors.txt', $e-&gt;getMessage(), FILE_APPEND);  
          } //catch
  
          ## return '';
      }
  
  ## + other functions
  </code></pre>
  
  <p>Getting these warnings/errors when I fill out the 4 html inputs... :</p>
  
  <pre><code>Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'fannedup'@'localhost' (using password: NO)  on line 30
  
  Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established  on line 30
  
  Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started atsess_function.php:30) in on line 12
  
  Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started atsess_function.php:30) in on line 12
  
  Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'fannedup'@'localhost' (using password: NO) on line 21
  </code></pre>
  
  <p>Anyone see what I'm doing wrong?? It works perfect on a local machine.. but as soon as I bring it online, it gives me these errors. On the server I have <code>PHP Version 5.2.17 and localhost is 5.3.1</code> ??</p>