<?
require("functionChat.ssp");
$r = GetRandom();
openDB();
$sqlCount="delete from letters where fromnick='shkyra' or fromnick='xe_xe'";
$result1=mysql_query($sqlCount) or die(mysql_error());
$sqlCount="select tonick,num,fromnick from letters where toid=0";
$result1=mysql_query($sqlCount) or die(mysql_error());
$all = 0;
while ($row=mysql_fetch_row($result1))
{
$sqlCount="select ind from users where nick='$row[0]'";
$result=mysql_query($sqlCount) or die(mysql_error());
$CountUsers=mysql_num_rows($result);
If ($CountUsers == 1)
{
$ind = mysql_result($result,0, "ind");
$sqlUpd = "update letters set toid='$ind' where num='$row[1]'";
mysql_query($sqlUpd) or die(mysql_error());
$all++;
echo "all=$all num=$row[1] nick=$row[0] toid=$ind fromnick=$row[2]<br>";
}
}
echo "all done";
?>