Jragon Posted July 10, 2010 Share Posted July 10, 2010 Hey guys, I want to add 1 every time I do use this script to visits My code: <?php //Start Configeration //database host address $host = 'localhost'; //username to the database $user = 'root'; //database password $pass = ''; //database name $dbname - 'iplog'; //table to be used $tbname = 'logged_ips'; //End Configeration //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //conects to the mysql server $connection = mysqli_connect($host, $user, $pass); mysql_select_db($dbname, $connection); //looks for duplacute ips if(!$dup = mysqli_query($connection, 'SELECT * FROM `logged_ips`')) { echo "Query error: ".$connection->error; die(); //stops script execution, for debugging purposes only - put proper error handling here } mysqli_free_result($dup); //checks to see if there is a duplecate name while($row = mysqli_fetch_assoc($dup)) { $ip_address = $row['Address_IP']; $visits = $row['Address_Visits'] +1; } if($ip_address != $_SERVER['REMOTE_ADDR']){ //inserts the ip in to the database $query = 'INSERT INTO `' . $dbname . '` (`Address_ID`, `Address_IP`, `Address_visits`); VALUES (\'0\', \'' . $ip . '\', \'1\');'; mysqli_query($connection, $query); }else{ //adds a visit to the database $query = "UPDATE `logged_ips` SET `Address_visits` = '++1' WHERE `ip_address` = $ip LIMIT 0,1"; mysqli_query($connection, $query); } //echos the ip echo $ip; ?> It is not working tho Any ideas would be liked =] Thanks Quote Link to comment Share on other sites More sharing options...
jskywalker Posted July 10, 2010 Share Posted July 10, 2010 SET `Address_visits` = '++1' change to: SET `Address_visits` = `Address_visits` + 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.