Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username="not doing";
- $password="that again.";
- $database="heh...";
- mysql_connect("localhost:/tmp/mysql5.sock",$username,$password);
- @mysql_select_db($database) or die ("Unable to connect to database");
- $query="SELECT * FROM soi_voting ORDER BY Time_Voted";
- $result=mysql_query($query);
- if ( !$result ) {
- die('Could not query:' . mysql_error());
- }
- $num = mysql_numrows($result);
- $visitor_ip=@$REMOTE_ADDR;
- $now = time();
- $found = False;
- for ( $i = 0; $i < $num; $i++){
- if ( mysql_result($result, $i, "IP") == $visitor_ip){
- $found = True;
- $update_query="UPDATE soi_voting SET Time_Voted = ".$now." WHERE IP = '".$visitor_ip."'";
- mysql_query($update_query);
- }
- }
- if ($found = False){
- $insert_query = "INSERT INTO soi_voting VALUES(\"" . $visitor_ip . "\"" . "," . $now . ")";
- mysql_query($insert_query);
- }
- ?>
Add Comment
Please, Sign In to add comment