data type issue with mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tarrigo
Forum Newbie
Posts: 8
Joined: Sat Nov 25, 2006 4:48 pm

data type issue with mysql

Post by tarrigo »

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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

did u make it a string ie.

Code: Select all

"<a href='#'> TEST LINK </a>"
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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You can also try LONGTEXT, but in reality I would say it has to do with what you are passing to the INSERT/UPDATE query. Can you show the query?
tarrigo
Forum Newbie
Posts: 8
Joined: Sat Nov 25, 2006 4:48 pm

the query

Post by tarrigo »

The query I pass is:


Code: Select all

MYSQL_QUERY( "INSERT INTO $table VALUES('','$First','$Last','$Email','$Phone','$Comments')");
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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Tell you... post the text of a post you know fails. Let us see that. It might explain what is happening.
tarrigo
Forum Newbie
Posts: 8
Joined: Sat Nov 25, 2006 4:48 pm

I think I will close this one

Post by tarrigo »

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
Post Reply