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

  • Home
  • SEARCH
  • 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 6801409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:05:48+00:00 2026-05-26T19:05:48+00:00

I have the following table in the database: id, username, email, old_ip, current_ip Everytime

  • 0

I have the following table in the database:

id, username, email, old_ip, current_ip

Everytime the user logs in, I want their current ip to be stored in current_ip. But before that I want to save their old_ip (from last login) so I thought I could move what is in current_ip to old_ip before copying the new data to current_ip.

I wrote this script when logging in:

........
$sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password'"); 
$login_check = mysql_num_rows($sql);
if($login_check > 0){ 
   while($row = mysql_fetch_array($sql)){ 
    // Get member ID into a session variable
    $id = $row["id"];   
    session_register('id'); 
    $_SESSION['id'] = $id;
    // Get member username into a session variable
    $username = $row["username"];   
    session_register('username'); 
    $_SESSION['username'] = $username;


    // IP getting
    $old_ip = mysql_query("SELECT current_ip FROM members WHERE id='$id'");
    $result_old_ip = $old_ip;
    $sql_setoldip = mysql_query("UPDATE members SET old_ip='".$result_old_ip."' WHERE id='$id'");


    $getip = getenv("REMOTE_ADDR");
    $current_ip = $getip;
    // Update ip in database
    mysql_query("UPDATE members SET current_ip='".$current_ip."' WHERE id='$id'");

}

The result I get in the old_ip feild is “Resource id #7” Any help please ?

  • 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-26T19:05:49+00:00Added an answer on May 26, 2026 at 7:05 pm

    mysql_query() statement returns a resource pointer to the result set, not the data itself. You’ll need to use mysql_fetch_array() in order to retrieve the actual data in the table.

    like this:

    $old_ip = mysql_query("SELECT current_ip FROM members WHERE id='$id'");
    $row = mysql_fetch_array($old_ip);
    $result_old_ip = $row['current_ip'];
    

    this will solve your problem.

    Hope this helps.

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

Sidebar

Related Questions

I have the following schema: Database: test. Table: per_login_user, Field: username (PK), password Database:
I have an order table in my database and once a user logs into
I have two tables in my database as following: Employee Table: Username, Name, Job,
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
I have the following table relationship in my database: Parent / \ Child1 Child2
I have the following listbox below which binds to a database table of image
I have no control over database schema and have the following (simplified) table structure:
I have a database with the following table: PATIENT (PATIENT_ID*, MEDICAL_EXAMINATIONS) where the field

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.