Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:59:10+00:00 2026-05-29T08:59:10+00:00

The code below seems to only return the first two digits of my IP

  • 0

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());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:59:11+00:00Added an answer on May 29, 2026 at 8:59 am

    There is absolutely nothing wrong with

    $ip2 = $_SERVER['REMOTE_ADDR'];
    

    You say it only seems to contain the first two digits, but I’m guessing you made this assumption because $query1 only contains that.

    The problem is that you’re using %d in sprintf() which attempts to get the integer value of $ip2. An IP address is not an integer, but a string, thus you should use %s.

    sprintf("INSERT INTO values VALUES (NULL, 'phoenix', %d, '%s', %d, '%s', '%s', NULL)",
         $submissionid, $fullurl, $uid, $ip1, $ip2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't seem to figure this out, see code below. Trying to make a GET
The below code seems like it should work; however, the blob in the database
I'm using the below code for a rollover effect, seems to be working okay!
The code below doesn't seem to work or find anything on an array. I'm
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Code below is not working as expected to detect if it is in design
Code below is working well as long as I have class ClassSameAssembly in same
The code below shows a sample that I've used recently to explain the different
The code below gives me this mysterious error, and i cannot fathom it. I
The code below works. But if I comment out the line Dim objRequest As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.