I have a form on my web site that allows new contacts to fill in their information. The information is then stored in a mysql database. One of the fields is a textarea field so the user can type as much as they want.
In mysql I have associated that textarea field with the datatype of "text".
After a lot of trial and error I am not sure if length of text is the issue but more of what kind of text is going into it. Are there limitations to what kind of text you can put in this field. I do notice that if I try to put in for instance as a test:
<a href='#'> Test link </a>
The result is that a new record is not created for that submission. To get it to work I have URLENCODED before the data is submitted into the database and that does allow it to work, but I am just wondering if there is a list of characters or an article that might shed some light on restrictions because URLENCODE did not solve all my issues regarding what I inputted into the form.
Tony
data type issue with mysql
Moderator: General Moderators
Have a look at http://www.php.net/mysql_real_escape_string.
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
did u make it a string ie.
as long as the entire line is recognised as a string, the TEXT datatype should not have a problem with it, but if so BLOB may work, or if its under 255 characters, use VARCHAR.
Code: Select all
"<a href='#'> TEST LINK </a>"- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
the query
The query I pass is:
As mentioned it works fine if I just have a user type a standard message. However if someone puts HTML code in it does seem to error out unless I URLENCODE it. Even then it is not fullproof. I was hoping any type of text could be placed in, but there might be limitations.
Code: Select all
MYSQL_QUERY( "INSERT INTO $table VALUES('','$First','$Last','$Email','$Phone','$Comments')");- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I think I will close this one
I have tried to find some code that will cause it to not work but have come up short. The thing just keeps working. I know i should think that is good, but at this point I will move on to other things. Since the form is just for some user input and nothing incredibly complex, I think I will use my time more wisely and try to figure out other issues.
Thanks for all the help though. It got me started down other paths for more information.
That was valuable.
Tony
Thanks for all the help though. It got me started down other paths for more information.
That was valuable.
Tony