<?php
include '../wap/config.php';
if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) {
echo ("пЫЙВЛБ РПДЛМАЮЕОЙС Л вд!\n");
};
pg_query($conn,"begin;");
$res=pg_query($conn,"select fr_u from chat where id='$id';");
$uid=pg_result($res,0,0);
pg_query($conn,"update users set posts=(select posts from users where id='$uid')-1 where id='$uid';");
pg_query($conn,"delete from chat where id='$id';");
pg_query($conn,"end;");
pg_close($conn);
$link=sprintf("Location: chat.php?action=main&r=%s", $r);
header($link);
?>