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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:50:01+00:00 2026-06-03T09:50:01+00:00

Here is my code I’m trying to use to store the ip address of

  • 0

Here is my code I’m trying to use to store the ip address of the client. I’m trying to store the ip address to an unsigned int, by trying to do something seen in this question: Which MySQL datatype to use for an IP address?

Here is my code:

$client_ip = $_SERVER['REMOTE_ADDR'];

$ip_insert = "SELECT INET_ATON('$client_ip')";

$sql = "INSERT INTO rtv_sign_cispa (name_cispa,ip_cispa,email_cispa,message_cispa) VALUES ('$name','$ip_insert','$email','$message')";

There are other things in that statement being stored but just ignore those ones, they work, it’s the ip address that isn’t.

Error:

Error: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘192.168.2.1’)’,’email@email.com’,’Hmmmm’)’ at line 1

The ip address after near does in fact show the correct IP, I just switched it to a local ip for security reasons of course. email@email.com and Hmmm is from a form that is filled out to activate this so don’t really mind that.

Does anyone know what I’m doing wrong? I’m kinda new to SQL.

  • 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-06-03T09:50:02+00:00Added an answer on June 3, 2026 at 9:50 am

    You are doing this:

    $sql = "INSERT INTO rtv_sign_cispa (name_cispa,ip_cispa,email_cispa,message_cispa) VALUES ('$name',SELECT INET_ATON('$client_ip'),'$email','$message')";
    

    Because you are setting:

    $ip_insert = "SELECT INET_ATON('$client_ip')";
    

    and it must be:

    $ip_insert = "INET_ATON('$client_ip')";
    

    This is the way to do it:

    $sql = "INSERT INTO rtv_sign_cispa (name_cispa,ip_cispa,email_cispa,message_cispa) VALUES ('$name',INET_ATON('$client_ip'),'$email','$message')";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to match this block here /code\ int foo(string $bar, int $bleh); Simple
Ok the error is showing up somewhere in this here code if($error==false) { $query
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
Here is code example class A{ int i; public: A(int i) : i(i) {}
enter code here My problem is this: in this database the junction table contains
i've found a shake effect in stackoverflow question ( here ) Code is like
Here is code i saw in a C program , i knew this piece
I have this code to remove an existing meta tag to which i dont
Here code of my project. I use direct Tcp connection But i get Could
Here is code from MSDN . I don't understand why the work isn't just

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.