title: how can i resolve this error ? [function.mysql-real-escape-string]
body: <p>I use this code :</p>
  
  <pre><code>&lt;?php
      // Get values from form
      $name= mysql_real_escape_string($_POST['name']);
      if (empty($name)) {
          echo "No information has entered";
          echo "&lt;br/&gt;";
          echo "&lt;br/&gt;";
          echo "&lt;a href='index.php'&gt;Return to Homepage&lt;/a&gt;";
          exit;
      }
  
      $host="localhost"; // Host name
      $username="root"; // Mysql username
      $password=""; // Mysql password
      $db_name="pin"; // Database name
      $tbl_name="test"; // Table name
  
      // Connect to server and select database.
          mysql_connect("$host", "$username", "$password")or die("cannot connect");
          mysql_select_db("$db_name")or die("cannot select DB");
  
              // Insert data into mysql
              $sql = "UPDATE $tbl_name SET `Used` = '1' WHERE `test`.`Code` =$name;";
              //echo $sql; exit;
              $result=mysql_query($sql);
  
              // if successfully insert data into database, displays message "Successful".
              if($result){
                  echo "Your Information &lt;/br&gt;";
                  echo "&lt;BR&gt;";
                  echo "&lt;a href='index.html'&gt;&lt;/a&gt;";
                  $result = mysql_query("SELECT Code FROM `test` WHERE  `Code` =$name" );
                      while ($row = mysql_fetch_array($result)) {
                              printf("Code: %s &lt;/br&gt;", $row[0]); 
                                  $foundcode=$row[0];
                      }
                      if (!empty($foundcode)) {
                          echo "&lt;BR&gt;";
                          echo "&lt;a href='".$foundcode.".pdf'&gt;Click here to download.&lt;/a&gt;";
                      }
                          if (empty($foundcode)){
                          echo "&lt;BR&gt;";
                          echo "Password is wrong";
                          }
                          mysql_free_result($result);
                  echo "&lt;BR&gt;";
                  echo "&lt;BR&gt;";
                  echo "&lt;BR&gt;";
                  echo "&lt;a href='index.php'&gt;Exit&lt;/a&gt;";
              }
  
              else {
                  echo nl2br ("Entered Information are not valid, Please enter valid information &lt;/br&gt;&lt;/br&gt;");
                  echo "&lt;a href='index.php'&gt;Return to Homepage&lt;/a&gt;&lt;/br&gt;&lt;/br&gt;";
              }
  
          // close connection
          mysql_close();
  ?&gt;
  </code></pre>
  
  <p>but i receive this error:</p>
  
  <pre><code>Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'root'@'localhost' (using password: NO)
  </code></pre>
  
  <p>I read some help but i can't fix it .
  I read some answer about this problem like:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/10689349/fatal-error-call-to-a-member-function-prepare-on-a-non-object-in">Fatal error: Call to a member function prepare() on a non-object in</a>
  <a href="https://stackoverflow.com/questions/7607997/php-call-to-a-member-function-prepare-on-a-non-object-error">PHP Call to a member function prepare() on a non-object error</a>
  <a href="https://stackoverflow.com/questions/6837403/fatal-error-call-to-a-member-function-prepare-on-a-non-object-with-pdo">Fatal error: Call to a member function prepare() on a non-object with PDO</a></li>
  </ol>
  
  <p>Although i change the DB user &amp; pass but that problem still is Exist.</p>