Tarte Posted December 6, 2006 Share Posted December 6, 2006 mysql_connect(" ", " ", " ");mysql_select_db(" ");$retour = mysql_query('SELECT COUNT(*) AS nbre_entrees FROM news WHERE ip=\'' . $_SERVER['REMOTE_ADDR'] . '\'');$donnees = mysql_fetch_array($retour);if ($donnees['nbre_entrees'] == 0) { mysql_query('INSERT INTO news VALUES(\'' . $_SERVER['REMOTE_ADDR'] . '\', ' . time() . ')');}else { mysql_query('UPDATE news SET timestamp=' . time() . ' WHERE ip=\'' . $_SERVER['REMOTE_ADDR'] . '\'');}$timestamp_5min = time() - (60 * 5); // 60 * 5 = nombre de secondes écoulées en 5 minutesmysql_query('DELETE FROM news WHERE timestamp < ' . $timestamp_5min);$retour = mysql_query('SELECT COUNT(*) AS nbre_entrees FROM news');$donnees = mysql_fetch_array($retour);echo '<p>Il y a actuellement ' . $donnees['nbre_entrees'] . ' visiteurs connectés sur mon site !</p>';?> I would tell you guys what Error i get, but it seems like there is error on pretty much every lines *lol* so..Thanks for helping me :)PS : I named it ''news'' for some dumb reason, but it has nothing to do with news, it's supposed to show statistic -.- Link to comment Share on other sites More sharing options...
justsomeguy Posted December 6, 2006 Share Posted December 6, 2006 Actually, that code looks fine. I don't see any syntax errors. Assuming you have the right connection info for mysql, and assuming the news table is a 2-column table with ip and timestamp, everything should be working. Link to comment Share on other sites More sharing options...
Tarte Posted December 6, 2006 Author Share Posted December 6, 2006 All right thanks alot, It's probably a porblem with my server, i'll try it on my localhost. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now