Search code examples
phpmysqlinsertmysql-error-1064

Trying to insert IP address but get an error


I'm trying to insert IP addresses into LastIP(An unsigned integer)

INSERT INTO user_entry (UPC, StateID, StoreID,CityID,Price,Count,LastIP) VALUES (885909301378,1,1,1,170,0,INET_ATON(127.0.0.1))

Error:

1064 - 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 '.0.1))' at line 1


Solution

  • You need to add quotes:

    INSERT INTO user_entry
    (UPC, StateID, StoreID,CityID,Price,Count,LastIP) VALUES 
    (885909301378,1,1,1,170,0,INET_ATON("127.0.0.1"))
    

    Source: Manual