Хочу организовать счетчик просмотра статьи, запоминающий айпишник, но почему-то не выполняется условие...
Айпишник с id статьи не добавляется в бд
$page_result = mysql_query("
SELECT
`pages`.`id`,
`pages`.`page_name`,
`arts`.`id` AS arts_id,
`arts`.`title` AS arts_title,
`arts`.`meta_d`,
`arts`.`meta_k`,
DATE_FORMAT(`date`, '%d/%m/%y') AS date,
`arts`.`cat` AS arts_cat,
`arts`.`image`,
`arts`.`views`,
`arts`.`text`,
`arts`.`url` AS arts_url,
`users`.`usr_name`,
`users`.`id` AS usr_id,
`category`.`id` AS cat_id,
`category`.`cat_name`,
`category`.`url` AS cat_url
FROM `pages`, `arts`, `users`, `category`
WHERE page_name ='art'
AND `arts`.`cat` = `category`.`id`
AND `arts`.`author` = `users`.`id`
AND `arts`.`url` = '$url'",$db);
$page_value = mysql_fetch_array($page_result);
$art_id = $page_value['arts_id'];
$ip_viewer = $_SERVER["REMOTE_ADDR"];
$query_views = "
SELECT
`viewer_art`.`id_art`,
`viewer_art`.`ip_viewer`,
`arts`.`id`
FROM `viewer_art`, `arts`
WHERE `viewer_art`.`id_art` = `arts`.`id`
AND `viewer_art`.`ip_viewer` = '$ip_viewer'
AND `arts`.`id` = '$art_id'";
$views = mysql_query($query_views,$db);
if(mysql_num_rows($views) == NULL){
$views_insert = mysql_query("INSERT INTO `ip_viewer` (ip, id_art) VALUES ('$ip_viewer', '$id_art')",$db);
$views_update = mysql_query("UPDATE `arts` SET `views`=`views`+1 WHERE `arts`.`url` = '$url'",$db);
}
else{
exit;
}