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 6384789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:49:08+00:00 2026-05-25T02:49:08+00:00

Getting users ip adress with this piece of code. I have unsigned int field

  • 0

Getting users ip adress with this piece of code. I have unsigned int field for ip’s in my db table

   <?php
    if (!empty($_SERVER['HTTP_CLIENT_IP'])){
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    //proxy check
    }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    $ip = ip2long($ip);
    ?>

Testing website in local server. The problem is, getting ‘63177408abbad957ed13ae1a2dd3e0b3ed47bd0b48ffcb362’ after ip2long conversion. Tried

    $ip=$_SERVER['REMOTE_ADDR'];
    $ip = ip2long($ip);

too. Still no success. How can i fix it?

  • 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-25T02:49:09+00:00Added an answer on May 25, 2026 at 2:49 am

    You’re most likely on a 32bit install of PHP, which is corrupting the IP address. Try to do the conversion inside mysql, which doesn’t suffer the problem:

    $ip = mysql_real_escape_string('127.0.0.1');
    $sql = "INSERT INTO yourtable (ip) VALUES (INET_ATON('$ip'));";
    

    The other alternative is to force PHP to treat it as an unsigned integer, as per the Notes on the ip2long man page: $ip = sprintf('%u', ip2long($ip));

    As well, remember that IPv6 will be widespread "any day now", and you’ll need to use a 128bit integer to store those values (which MySQL doesn’t support – it’d have to be two 64bit bigints at least).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just getting started using MVC in ASP.NET, I'm going to have it so users
I am getting this error after adding the libxml2.2.dylib file Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1
I have a mySQL table with records of users who have visited my site.
I'm trying to update a email field in Mysql through php. i keep getting
The error I'm getting: in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable Cliff notes:
Is there a way to prevent users from getting into SQL Server Management Studio
I am getting syntax error with the following statement REPLACE INTO users (screenname, token,
I keep getting duplicate entries in my database because of impatient users clicking the
I'm getting awful lot of spam to my forums where only registered users can
I've been having trouble getting my ASP.NET application to automatically log users into the

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.