I use this code :
<?php
    // Get values from form
    $name= mysql_real_escape_string($_POST['name']);
    if (empty($name)) {
        echo "No information has entered";
        echo "<br/>";
        echo "<br/>";
        echo "<a href='index.php'>Return to Homepage</a>";
        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 </br>";
                echo "<BR>";
                echo "<a href='index.html'></a>";
                $result = mysql_query("SELECT Code FROM `test` WHERE  `Code` =$name" );
                    while ($row = mysql_fetch_array($result)) {
                            printf("Code: %s </br>", $row[0]); 
                                $foundcode=$row[0];
                    }
                    if (!empty($foundcode)) {
                        echo "<BR>";
                        echo "<a href='".$foundcode.".pdf'>Click here to download.</a>";
                    }
                        if (empty($foundcode)){
                        echo "<BR>";
                        echo "Password is wrong";
                        }
                        mysql_free_result($result);
                echo "<BR>";
                echo "<BR>";
                echo "<BR>";
                echo "<a href='index.php'>Exit</a>";
            }
            else {
                echo nl2br ("Entered Information are not valid, Please enter valid information </br></br>");
                echo "<a href='index.php'>Return to Homepage</a></br></br>";
            }
        // close connection
        mysql_close();
?>
but i receive this error:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'root'@'localhost' (using password: NO)
I read some help but i can't fix it . I read some answer about this problem like:
- Fatal error: Call to a member function prepare() on a non-object in PHP Call to a member function prepare() on a non-object error Fatal error: Call to a member function prepare() on a non-object with PDO
Although i change the DB user & pass but that problem still is Exist.
 
     
    