Im currently using this code...

PHP Code:
    // connect to and select the database
    
@mysql_connect($host,$user,$password) or die("&success=no&");
    @
mysql_select_db($dbname) or die("&success=no&");

    
// query the database and return an array of data
    
$result = @mysql_query("SELECT * FROM $tablename WHERE rand = $rand") or die("&success=no&"); 
i keep getting told not to use it and to now use PDO, can someone please show me exactly how i change the above code to PDO