The code below seems to only return the first two digits of my IP address. How can I get the full IP address?
$ip2 = $_SERVER['REMOTE_ADDR'];
EDIT: I’m putting it into MySQL as varchar(30) latin1_swedish_ci. Is there a format change that will show the full IP?
EDIT 2: Maybe it’s my query that’s changing the format. Here it is:
$query1 = sprintf("INSERT INTO values VALUES (NULL, 'phoenix', %d, '%s', %d, %d, %d, NULL)", $submissionid, $fullurl, $uid, $ip1, $ip2);
mysql_query($query1) or die(mysql_error());
There is absolutely nothing wrong with
You say it only seems to contain the first two digits, but I’m guessing you made this assumption because
$query1only contains that.The problem is that you’re using
%dinsprintf()which attempts to get the integer value of$ip2. An IP address is not an integer, but a string, thus you should use%s.