Jump to content

greekscientist

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

greekscientist's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i said from the beggining that it doesn`t enter the loop m8. Sorry if i become boring and thanks for your help. I will keep trying until i learn my mistake
  2. I checked the logs and i dont have errors. I dont have mysql errors either. The problem is just the functionality edit: i want to learn what i do wrong, not to just copy another program
  3. Basically the script should show the unique visitors. I upload it and tested it. O refresh the page and it count 1,2,3 + unique visitors. It should only show 1 unique visitors at that situation. The thing is that it doesn`t execute those code after the while loop. Is something like ... search sql table for a record. If its exist update it, if not insert new record. That script only enters new records.
  4. Hello and thanks for the interest! As i allready write "It doesn`t get inside the while to execute the next lines" I just provide the code because i think that is needed Thanks again!
  5. I found a script at the net but it have a small mistake. I tried 3 hours but i can`t get it work. The problem is i believe at those lines $get_ip = mysql_query("SELECT * FROM ".$db_table." WHERE vis_ip=".$vis_ip." LIMIT 1"); while ($row=mysql_fetch_object($get_ip)) It doesn`t get inside the while to execute the next lines the whole script is that <?php // config variables $tframe = 1000; // time frame (minutes) to count active users // database connection details $db_host = "localhost"; // hostname of your MySQL server. You most likely don't have to change this $db_name = "**_fruits"; // database name $db_user = "**_apples"; // database user $db_pass = "**"; // database password $db_table= "visits"; // table name // Lets open up a connection to the database $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); // On to the counter processing... $vis_ip = ip2long($_SERVER['REMOTE_ADDR']); $time = time(); $new_vis = 1; // update database for returning visitor $get_ip = mysql_query("SELECT * FROM ".$db_table." WHERE vis_ip=".$vis_ip." LIMIT 1"); while ($row=mysql_fetch_object($get_ip)) { mysql_query("UPDATE ".$db_table." SET vis_time='$time' WHERE vis_ip='$vis_ip'") or die (mysql_error()); $new_vis = 0; } // add to database for new visitor if ($new_vis == 1) { mysql_query("INSERT INTO ".$db_table." (vis_ip, vis_time) VALUES ('$vis_ip','$time')") or die (mysql_error()); } // done processing the visit, now lets see how many total visitors are online $tcheck = time() - (60 * $tframe); $query = mysql_query("SELECT * FROM ".$db_table." WHERE vis_time > $tcheck"); $onlinenow = mysql_num_rows($query); // show number of visitors on screen if($onlinenow == 1) { echo"currently $onlinenow visitor online"; } else { echo"currently $onlinenow visitors online"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.