webbwbb Posted December 20, 2009 Share Posted December 20, 2009 I have a form with a pretty simple PHP processor/verification page to add it to my database. It usually works unless my text gets too long/complex. After approximately 200 characters it no longer saves to the database. I had it echo the value on the processing/submittal page and I can tell that it is getting the data properly. Here is the code I have to write it into my database: $result = mysql_query("INSERT INTO news (title, dtime, text1, text2) VALUES ('$title',NOW(),'$text1','$text2')",$connect); It is having problems with text2. It was originally just TEXT but I tried changing it to LONGTEXT without results. Any help would be greatly appreciated. EDIT: When it rejects the entry it does not report any errors. Quote Link to comment https://forums.phpfreaks.com/topic/185800-form-inconsistently-submits-data/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 20, 2009 Share Posted December 20, 2009 EDIT: When it rejects the entry it does not report any errors. What's your error checking logic in your code? Is is using mysql_error() so that you would know why the query is failing? Quote Link to comment https://forums.phpfreaks.com/topic/185800-form-inconsistently-submits-data/#findComment-981070 Share on other sites More sharing options...
webbwbb Posted December 20, 2009 Author Share Posted December 20, 2009 echo .mysql_error(); I just tried again with much longer text and got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use It does not report that unless there is a rather large amount of text entered. My server is using MySQL 5.0.32 Quote Link to comment https://forums.phpfreaks.com/topic/185800-form-inconsistently-submits-data/#findComment-981079 Share on other sites More sharing options...
Kryptix Posted December 20, 2009 Share Posted December 20, 2009 echo .mysql_error(); I just tried again with much longer text and got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use It does not report that unless there is a rather large amount of text entered. My server is using MySQL 5.0.32 You're probably using quotes (" or ') in the text you're writing which are counting as the query and causing syntax errors. For example: VALUES ('hi title',NOW(),'who's up for some syntax errors?','this is some text')",$connect); Use PHP's htmlspecialchars() around the varaible before querying it. Quote Link to comment https://forums.phpfreaks.com/topic/185800-form-inconsistently-submits-data/#findComment-981103 Share on other sites More sharing options...
webbwbb Posted December 20, 2009 Author Share Posted December 20, 2009 That was it Thank you for your help. I hadn't even considered that possibility. Quote Link to comment https://forums.phpfreaks.com/topic/185800-form-inconsistently-submits-data/#findComment-981111 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.