![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Super2
-
Posts
7 -
Joined
-
Last visited
Never
Posts posted by Super2
-
-
$ip does not contain a value.
It has
$ip = $_SERVER['REMOTE_ADDR'];
And it`s adding the data only ones... Then it seems to be trying to add it one more time instead of adding $impresiq ....
-
I tried making ip Primary key and using
if ($ip == $row['ip']){ $impresiq = $row['impresiq'] + 1; $query ="UPDATE `visitor` SET impresiq = '$impresiq' WHERE ip = '$ip' "; $do = mysql_query($query) or die("Greshka3:".mysql_error()); }else{ $query = "INSERT INTO `visitor` (ip , uniq, data) VALUES ('$ip', '1', '$data')"; $do = mysql_query($query) or die("Greshka2:".mysql_error()); }
But it gives me and error....
Duplicate entry '' for key 1 -
Hey guys,
I was just wondering in how do I exit an html frameset as I have a link which has to redirect back to the index page as shown below, which should not have the frames.
Any help would be great thanks.
header("location:index.php");
Is that gonna work:
<FORM>
<INPUT type="button" value="Click here to go back" onClick="history.back()">
</FORM>
or
<a href="#" onClick="history.go(-1)">Back</a>
-
You still have to give it 4 values though right?
Just do:
$query = "INSERT INTO `visitor` (id, ip , uniqe, date) VALUES (NULL, '$ip', '1', '$date')";
If it is an auto_increment.
You need to put quotes around the values you pass in too.
Is the word 'uniqe' suppose to be 'unique'?
Yeah it is supposed to
but i already used everywhere that
Now i`m using:
$ip = $_SERVER['REMOTE_ADDR']; $date = date("d.m.Y"); $query = "SELECT * FROM `visitor`"; $res = mysql_query($query) or die("Greshka ".mysql_error()); while($row = mysql_fetch_array($res)) { if($date == $row['date']){ if ($ip != $row['ip']){ $query = "INSERT INTO `visitor` (ip , uniqe, date) VALUES ('$ip', '1', '$date')"; $do = mysql_query($query) or die("Greshka2:".mysql_error()); }elseif($row['uniqe'] == 1) { $impresiq = $row['impresiq'] + 1; $query ="UPDATE `visitor` SET impresiq = '$impresiq' WHERE ip = '$ip' "; $do = mysql_query($query) or die("Greshka3:".mysql_error()); } } }
But again there are no signs of live.... The strange is that it returns no error.....
p.s. id is auto_increment
ps2. That is my table:
$insert = "CREATE TABLE `visitor` ( `id` int(20) NOT NULL auto_increment, `ip` varchar(255) default NULL, `date` varchar(10) default NULL, `impresiq` varchar(255) default NULL, `uniqe` varchar(255) default NULL, PRIMARY KEY (`id`) )";
-
Hi guys,
I`m new to this forum
I`m trying to make a php counter, but it just didn`t work...
Here is my code. It returns no error, but it is not working
$ip = $_SERVER['REMOTE_ADDR']; $date = date("d.m.Y"); $query = "SELECT * FROM `visitor`"; $res = mysql_query($query) or die("Greshka ".mysql_error()); while($row = mysql_fetch_array($res)) { if($date == $row['date']){ if ($ip != $row['ip']){ $query = "INSERT INTO `visitor` (id, ip , uniqe, date) VALUES ($ip, 1, $date)"; $do = mysql_query($query) or die("Greshka2:".mysql_error()); }else{ $impresiq = $row['impresiq'] + 1; $query ="UPDATE counter SET count = '$count' WHERE ip = '$ip' "; $do = mysql_query($query) or die("Greshka3:".mysql_error()); } } } echo $impresiq." refreshes<br/>\n"; echo "Ip-to vi e ".$ip."<br/> na"; echo $date;
-
in some of the form`s fields entries are numbers and if they are not - returns alert mesage or some message??
Does someone have any idea?
Sry about the English :) (if there are any mistakes )
Question about counter
in PHP Coding Help
Posted
I have some error in the IF statement i think, but i can`t find it....
I want it like that:
If the ip is new it is recorded in 'ip' and unique is being set to 1.
Or if it is not new > impresiq/refreshes is being increased: