4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Getting IP Addresses using PHP on Windows
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Mon Jun 07, 2004 5:48 pm (13 years, 6 months ago) Reply with QuoteBack to Top

Right, I have a speed test on a windows box which saves the results of the test to a database with IP and Hostnames, the script is PHP and below, the problem I have is that the IP address is not saved and the field inserted in to the database is blank, but the hostname is saved correctly.

The same script works fine on a linux box, could anyone tell me how I could fix this, the code I use to get the IP is located below.

Code:
<?php

if ($mysql == True) {
   $link = mysql_connect($database["host"], $database["login"],
      $database["password"])
       or die("Could not connect");
   mysql_select_db($database["database"])
       or die("Could not select database");

   $ip = $_SERVER['REMOTE_ADDR'];
   $name = gethostbyaddr($ip);
   $query = "INSERT INTO readings (speed, ip, name) VALUES ($kbps, '$REMOTE_ADDR', '$name')";
   $result = mysql_query($query)
       or die("Query failed");
}

?>
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Mon Jun 07, 2004 7:42 pm (13 years, 6 months ago) Reply with QuoteBack to Top

tis ok, fixed it.
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.053053 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme