Inserting script tags (or SQL) is a problem only if you cannot be sure that it is not, that it could be a problem.
Tag
A <script> in the middle of the comment someone is submitting will not damage your server, and it will not damage your database. It would be painful if you did not take the appropriate measures, it would be a page that includes a comment when you subsequently serve it, and it gets into the client browser. To prevent this from happening, your code that prepares the page must ensure that the content provided by the user is always cleared before it is exposed to an uninformed interpreter. In this case, this uninformed interpreter is a client web browser. In fact, your client web browser really includes two uninformed interpreters: an HTML parser and a linking engine and a Javascript interpreter.
Another important example of an ignorant interpreter is your database server. Note that the <script> (almost certainly) is safe for your database because "" means nothing in SQL. These are other types of input that cause problems for SQL, such as quotes in strings (which are harmless to your HTML pages!).
Stackoverflow would be pretty lame if I couldnโt put the <script> tags in my answers, as I am doing now. The same goes for examples of SQL injection attacks. Recently, someone linked a page to some famous American bank, where a large <textarea> was marked with a warning not to include the characters "<" or ">" in what you typed. As expected, the bank made fun of hundreds of Reddit comments, and rightly so.
In the same way that you โclearโ the content provided by the user depends on the ignorant interpreter to whom you deliver it. If it is deleted in the middle of the HTML markup, you must ensure that the "<", ">" and "&" characters are encoded as HTML destinations. (You might also want to use quote characters if the content might be in the attribute value of the HTML element.) If the content needs to be removed in Javascript, you may not need to worry about HTML escaping, but you need to worry about quotes and possibly Unicode characters outside the 7-bit range.
source share