when a user leaves a comment , say a long comment normally youd hit enter button a couple of times to create a new paragraph. on my comment script even after doing that all the text gets stuck together with no breaks, how to fix that? i did not include my comment script because it seems like its not needed just something i must be missing. if i do need to post it let me know
create a unique id for that comment then write a script that tells whether that unique id is existing in the database or not.
i dont think your answer has anything to do with my question. what i mean is comments submitted on my site dont contain any line breaks in between paragraphs of that comment. For example i type free then press enter then type free agin then press enter then type free again the out put should be like Free Free Free but the output that comes out is Free Free Free
Precisely what hassanahmad2 said. I would also take the opportunity to enforce some validation checks on the user input. Never trust the user to input correct data. A quick google search on the subject brought up this seemingly decent resource. I recommend reading about the topic of validation and verification as soon as you can!
Example code you should use: function Escape($Data) { return mysql_real_escape_string($Data); } $Comment=Escape($_POST['comment']); $UserID=Escape($_POST['userid']); PHP: That is a very basic example, but if you would like more help, simply post the script and we can help secure it.
I've had this problem myself before, i simply did this: function replace($txt) { $txt = str_replace(array("\r\n", "\n", "\r"), '<br>', $txt); return $txt; } PHP: Then, Where you're echoing put this: echo "".replace(FreeFreeFree).""; PHP: The output of this will be: Free Free Free Hope this helps.
thanks everyone for your reply's, still i guess the 1 problem is that the comments are stored without the \r\n or \n or \r or whatever, there getting stored exactly as there written. Could it be that the table column is of type text ?
<form method=post action='comment.php' name='form'>Name <input type=text name=name size=30> Rating <select name="vote"> <option value="5">(5 Stars) Best</option> <option value="4">(4 Stars) Better</option> <option value="3">(3 Stars) Good</option> <option value="2">(2 Stars) Fair</option> <option value="1">(1 Stars) Poor</option> </select> <textarea name=comments rows=7 cols=60></textarea><input onclick='DoSubmit ()' type='button' value='Submit Review'></form> Basically this is all the script, then comment.php uses the GET and insert into mysql
Correction to that, they ARE...\r\n is actually \x10\x13 or...enter key...it is not an HTML character, meaning...it does not show up as such. If you were to use "SELECT" and use nl2br it would then turn the enter key to <br> instead...Thus fixing the issue. I am available via instant messenger if needed.
that fixed it, needed nl2br.... Thank you very much, adding rep, also if youd like pm me your paypal and i will send $5 over, i know its not much if you are a programmer for hire maybe even send your messaging details