{% else-1 %}
(19 окт 2014, 23:42) (0/0) [0]
Народ вот код $mod = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (!mysql_result(mysql_query("SELECT COUNT(id) FROM `online` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' AND `ua` = '" . mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']) . "'"*, 0))
mysql_query("INSERT INTO `online` SET
`ip` = '" . $_SERVER['REMOTE_ADDR'] . "',
`ua` = '" . mysql_real_escape_string(htmlspecialchars($_SERVER['HTTP_USER_AGENT'])) . "',
`mainpage` = '$mainpage',
`time` = '" . time() . "',
`go` = '1',
`url` = '" . mysql_real_escape_string(htmlspecialchars($mod)) . "'"*;
else
mysql_query("UPDATE `online` SET
`mainpage` = '$mainpage',
`time` = '" . time() . "',
`go` = `go` + '1',
`url` = '" . mysql_real_escape_string(htmlspecialchars($mod)) . "' WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' LIMIT 1"*;
///Удаляем неактивных пользователей
mysql_query("DELETE FROM `online` WHERE `time` < '" . (time() - 300) . "'"*;
я пишу таблу так
CREATE TABLE IF NOT EXISTS `online` (
`ip` varchar(20) NOT NULL,
`ua` varchar(32) NOT NULL,
`time` int(11) NOT NULL,
`url` varchar(64) NOT NULL,
`go` varchar(11) NOT NULL,
`mainpage` int(15) NOT NULL,
KEY `ip_2` (`ip`,`ua`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Коряво пашет. Где ошибся?
  • 1 из 1