+ 3
Maximum length of text in html
I'm trying to insert some text to my database. but when I inserted it, it says that data has been inserted but it is not. I then try with shorter text and it could be inserted. my database colum type is varchar 2000.
8 Réponses
+ 4
Ah okay, that makes sense. The string of text you're sending to your database contained special characters, so it was trying to process it as such, rather than as plain text. When you use that MySQL command, it is escaping all of those special characters so you don't get that effect. Make sure you always use those systems because people can actually mess up your database by injecting it and running commands from the server that way.
+ 5
When you say "it says that data has been inserted," what is telling you that it was inserted? Your HTML code? The database itself?
It sounds more like an issue with your table's structure, but hard to say without being able to see any of the data you're talking about. What string of text are you trying to insert? If you directly put it as an inquiry to your database rather than from your website, what happens? Does the data appear? Error message?
If you increase the size of that field, does the same thing happen?
Throw some more information my way. More than happy to help you track it down.
+ 4
You're welcome!
As you can see, there is always much to be learned when we run into problems with our code. This simple problem also taught you about properly securing your database/code/SQL.
Best wishes to you on your journey!
+ 2
If you try using TEXT or LONGTEXT instead of VARCHAR, what happens?
+ 2
I found the solution, but I cannot make sense of it. I added mysql_real_escape_string and it could enter into my database. do you know the reason behind it?
+ 2
thank you
+ 1
I'm trying to insert a long text of word into my mysql database, when I increase the size of the colum nothing nothing has changed, it still will jot insert. but when I reduce the length of the text. it could be inserted into the db
+ 1
database text data type