Warning: # 1265 Data truncuted for column 'cart_ip' at row 1.

I wanted to add ip 127.0.0.1 to this entry since I work on a local machine and there is an error here. What could be the problem?

  • Show create table and which query results in an error. - cronfy

2 answers 2

The fact is that you specified the length of the cart_ip column less than you are trying to insert. For example, it may have been declared as varchar(6) , but should be 15.

Accordingly, it is necessary to hold ALTER TABLE and change the length of the column to the desired one. For more.

Example:

 ALTER TABLE myTable CHANGE cart_ip cart_ip VARCHAR(15); 

Yes, no, I have an int (100)

So especially for ip, you need to change the field type. For the string of chars in int does not fit, however.

  • Yes, no, I have an int (100) ... - Olexandr Pylypyshyn
  • one
    Worth int (100), and you enter a string? Seriously, nothing confuses you? - Ninazu
  • Thank you, Nizazu, for the answer. I'm still learning - Olexandr Pylypyshyn
  • @OlexandrPylypyshyn change the field type to the correct one - Alexey Shimansky
  • And he did. Thanks - Olexandr Pylypyshyn

To store IP in DB as a number, you need to convert it with the help of INET_ATON , which is basically more correct than storing the string. You can read more here.