Jump to content

Recommended Posts

Hello everyone. I have a script I use to log IPs of who comes onto my pages.

I actually have two questions on this.

 

I use the following script to pull the info from my database and echo the results onto the page;

 

mysql_query("INSERT INTO glowcount (ip) VALUES('".$count."' ) ") or die(mysql_error());
$thecount=mysql_query("SELECT * FROM glowcount ORDER BY count DESC");
$showthecount=mysql_fetch_assoc($thecount);
    echo $showthecount['count'];

 

Now, it works just fine, BUT it lists all the IPs, and the list is getting rather long.

Is there a way to show only a certain number of IPs? Like, limit it to the last 50 people that visited?

 

 

Also, to the second part. Like on Wordpresses IP tracker, I want it to show which page they were referred from. I do not know if this is possible with my current script to do, but if it is, I would like to know what to do to do it.

 

Here is my current script for GETTING IPs

 

$IP =$_SERVER['REMOTE_ADDR']; //Or whatever refined IP
$Requests =mysql_real_escape_string(print_r($_REQUEST,true)); //Grab server request vars
$Date =date('D M dS Y h:i a'); //The date, you can use other info..
$agent = getenv("HTTP_USER_AGENT"); //Or whatever refined IP

 

Now, this part of the script was not written for me, and I was helped on this a while back here on the forums. I am pulling Requests. Now when the person showed me this script, he did not tell me exactly what data the "Requests" holds. This may be the referrer, I don't know. That is why I am asking.

Link to comment
https://forums.phpfreaks.com/topic/185159-only-listing-a-certain-number/
Share on other sites

1.) You can use MySQL's LIMIT clause to specify a certain number of rows returned. Example

$query = "SELECT * FROM table LIMIT 50 ORDER BY id DESC";//get last 50 entries in database

 

2.) In addition to the IP address of the user, the $_SERVER super global has the referrer also (although beware, because this can be spoofed, and is sometimes not sent

 

$referrer = $_SEVER['HTTP_REFERER'];

 

1.) You can use MySQL's LIMIT clause to specify a certain number of rows returned. Example

$query = "SELECT * FROM table LIMIT 50 ORDER BY id DESC";//get last 50 entries in database

 

2.) In addition to the IP address of the user, the $_SERVER super global has the referrer also (although beware, because this can be spoofed, and is sometimes not sent

 

$referrer = $_SEVER['HTTP_REFERER'];

I added the LIMIT section to it to make it

 

$query=mysql_query("SELECT * FROM ip_table LIMIT 50 ORDER BY id DESC");

But it returns:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/e/s/o/esone/html/test/jsontest.php on line 30

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.