0

I'm trying to do an INSERT into a mysql db and it fails when any of the values are longer than 898 characters. Is there somewhere to get or, better, set this maximum value? I'll hack the string into chunks and store 'em in separate rows if I must, but I'd like to be able to insert up to 2k at a time.

I'm guessing this is php issue as using LONGTEXT or BLOB fields should be more than enough space in the db.

Thanks.

4
  • Do you receive an error from the DB or PHP? Commented Mar 2, 2009 at 3:16
  • You can do echo(mysql_error()); on the line after your query to see the error. Commented Mar 2, 2009 at 3:30
  • When you say 'it fails' what happens? Does it truncate the field or fail to insert, and if it fails what is the relevant error message? Commented Mar 2, 2009 at 3:38
  • What error messages if any are you getting? What is your code so that we can take a look? Are you using mysqli or mysql? Commented Mar 2, 2009 at 4:26

2 Answers 2

1

Side Note:

When you get into working with large blobs and text columns, you need to watch out for the MySQL max_allowed_packet variable. I believe it defaults to at least 1M.

Sign up to request clarification or add additional context in comments.

Comments

0

I'm assuming this is a varchar column you're trying to insert into? If so, I assume the maximum length has been set to 898 or 900 or something like that.

In MySQL 5 the total row size can be up to 65,536 bytes so a varchar can be defined to whatever size keeps the total row size under that.

If you need larger use text (65,536) or longtext (4 billion?).

1 Comment

I've said in my question that I'm using LONGTEXT and BLOB fields.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.