When I try to enter some very long data, (response from ChatGPT API) it doesn't get saved into sessions data which Im handling manually by storing in a MySQL table.

$_SESSION[$propertyName."-".$ID] = addslashes($propertyValue);
Uncaught mysqli_sql_exception: Data too long for column 'Data' at row 1

Data is of Type text latin1_swedish_ci

I thought type of text can handle large amounts of data.

  • What is Data column datatype precisely? What is the length of the data to be stored in this column?
    – Akina
    Commented Nov 5, 2023 at 21:12
  • The TEXT data type can handle string data that is somewhat long, but not unlimited. The limit for that data type is 64KB (i.e. a string whose length can be encoded in 16 bits). If your ChatGPT response is longer than that, it won't fit in a TEXT column. Commented Nov 6, 2023 at 3:37
  • I changed it to LONGTEXT - it seems to be okay now.
    – anjanesh
    Commented Nov 6, 2023 at 23:46


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.