Jump to content

Textarea


kelleydl
 Share

Recommended Posts

i have a textarea inside a form which is used for comments. for some reason users can enter a short bit of information such as 100 characters and shorter. at they can even enter LARGE amounts of text, but for some reason like this one post of 341 characters (with spaces) doesnt seem to load into the database. when click submit it goes to post.php and inside that i check to make sure the user entered text into uComment . if not do nothing, but if there is text put it into database. im not sure what the problem is... on debug it passes to the part where it enters information into the database and for some reason its just not entering the data into it. ive tried different string types like varchar(), text, longtext, blob..etc. and none of it seems to be working. any help? or maybe a different way to debug? i dont know

Link to comment
Share on other sites

A few random debugging thoughts:Are you saying short data (sub 100 chars) gets written, but longer doesn't? A different data type really should take care of that. But even if it's a short data type, the data should get truncated (I think). You wouldn't end up with nothing.How do you KNOW the data isn't getting written? The surest thing would be to examine it with phpMyAdminOr is NOTHING getting written, regardless of data length? You should echo the $_POST value before the database routine to see what your script is actually receiving."i check to make sure the user entered text into uComment" -- how does that routine work? Could be faulty.

Edited by Deirdre's Dad
Link to comment
Share on other sites

I'm saying that as far as I have been able to debug anything between 255 - 500 characters will not save into the database. Anything less and 255 and anything more than 500 has been able to just fine.I have looked at the phpMyAdmin and it is not entering into it, but everything has. I tried the echo $_POST before and after I insert the data into the database and it has the information just fine. I tried all the different data types in the database and it is all working the same way.To check if the user entered text into uComment, before I enter the data into the database I have an if statement.if($_POST['uComment']=="") {echo "You MUST enter something into the Comment box.";}else{ echo $_POST[uComment]; mysql_query("INSERT INTO Comments(name, location, moment, dateon, timeon) VALUES('$_POST[uName]', '$_POST[uLocation]', '$_POST[uComment]', '$date', '$time')");}

A few random debugging thoughts:Are you saying short data (sub 100 chars) gets written, but longer doesn't? A different data type really should take care of that. But even if it's a short data type, the data should get truncated (I think). You wouldn't end up with nothing.How do you KNOW the data isn't getting written? The surest thing would be to examine it with phpMyAdminOr is NOTHING getting written, regardless of data length? You should echo the $_POST value before the database routine to see what your script is actually receiving."i check to make sure the user entered text into uComment" -- how does that routine work? Could be faulty.
Link to comment
Share on other sites

anything between 255 - 500 characters
That sounds like an issue with a varchar field, the correct data type should be text. Don't just try all data types, look in the manual and figure out which one you need and use that. A text field holds up to 64kb of text. Have PHP print out the query and run the query directly in phpMyAdmin, if there are any problems phpMyAdmin will show an error. I noticed that you are not escaping your data, so if the data has a single quote in it there will be a problem.
Link to comment
Share on other sites

I noticed that you are not escaping your data, so if the data has a single quote in it there will be a problem.
Thanks. It was the escaping data that was problem. It works just fine now. What I did is below, took the $_POST variables and put them into a seperate variable after using mysql_real_escape_string() $udname = mysql_real_escape_string($_POST[uName]);$udlocation = mysql_real_escape_string($_POST[uLocation]);$udmoment = mysql_real_escape_string($_POST[uMoment]);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...