ltrem Posted September 17, 2009 Share Posted September 17, 2009 Not sure if its the right place... but here is the problems I have a Javascript function that get the value of a textarea and then send it to a php pages with AJAX... here is the URL.. http://www.xxx.com/commentFunction.php?comment=" + document.commentForm.comment.value ; Now, in the PHP... I retrieve the variable with $comment = $_GET["comment"]; And then insert the $comment in MySQL.. the problem is that when I retrieve the info from MySQL...there is no Linebreak...? How could I correct that? Thanks Link to comment https://forums.phpfreaks.com/topic/174612-solved-sending-textarea-value-with-ajax-how-to-insert-it-with-linebreak-in-mysql/ Share on other sites More sharing options...
ltrem Posted September 17, 2009 Author Share Posted September 17, 2009 More information... I tried to do alert(document.commentForm.comment.value); And the Alert message is displayed exactly as in the textarea (with the line break)... It seems that passing that value as a parameter in the URL just sanitize the variable and remove all the line break...?? Link to comment https://forums.phpfreaks.com/topic/174612-solved-sending-textarea-value-with-ajax-how-to-insert-it-with-linebreak-in-mysql/#findComment-920226 Share on other sites More sharing options...
kickstart Posted September 17, 2009 Share Posted September 17, 2009 Hi Not sure, but a brief look suggests that other people have had the same issue using get rather than post. Might be worth trying a post instead. All the best Keith Link to comment https://forums.phpfreaks.com/topic/174612-solved-sending-textarea-value-with-ajax-how-to-insert-it-with-linebreak-in-mysql/#findComment-920229 Share on other sites More sharing options...
ltrem Posted September 17, 2009 Author Share Posted September 17, 2009 Thanks for your answer kickstart... While trying to do it with the POST... I found this example -> http://www.captain.at/howto-ajax-form-post-request.php and there I say the encoreURI function! so I did http://www.xxx.com/commentFunction.php?comment=" + encoreURI(document.commentForm.comment.value); And in the PHP I did echo "<td><pre>" . urldecode($_GET["comment"]) . "</pre></td>"; Worked like a charm!!! Now I'll try to insert/retrieve from the Database to see how it run! Link to comment https://forums.phpfreaks.com/topic/174612-solved-sending-textarea-value-with-ajax-how-to-insert-it-with-linebreak-in-mysql/#findComment-920257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.