Try this
mysql_query("INSERT INTO pm (from, to, subject, message) VALUES ('$playerid', '$toid', '$subject', '$message')") or die(mysql_error($db_link));
please replace $db_link with variable u got when u connected to the db like:
$db_link = mysql_connect(...);
It will output the problem.
Please copy-paste it here.