title: What does it mean to escape a string?
body: <p>I was reading <a href="https://stackoverflow.com/questions/10645067/does-sessionusername-need-to-be-escaped-before-getting-into-an-sql-query">Does $_SESSION[&#39;username&#39;] need to be escaped before getting into an SQL query?</a> and it said "You need to escape every string you pass to the sql query, regardless of its origin". Now I know something like this is really basic. A Google search turned up over 20, 000 results. Stackoverflow alone had 20 pages of results but no one actually explains  what escaping a string is or how to do it. It is just assumed. Can you help me? I want to learn because as always I am making a web app in PHP. </p>
  
  <p>I have looked at:
  <a href="https://stackoverflow.com/questions/1653040/inserting-escape-characters">Inserting Escape Characters</a>, <a href="https://stackoverflow.com/questions/1367322/what-are-all-the-escape-characters-in-java">What are all the escape characters in Java?</a>, 
  <a href="https://stackoverflow.com/questions/9341068/cant-escape-a-string-with-addcslashes">Cant escape a string with addcslashes()</a>, 
  <a href="https://stackoverflow.com/questions/2237703/escape-caracter">Escape character</a>, 
  <a href="https://stackoverflow.com/questions/6327679/what-does-mysql-real-escape-string-really-do">what does mysql_real_escape_string() really do?</a>, 
  <a href="https://stackoverflow.com/questions/9389191/how-can-i-escape-double-quotes-from-a-string-in-php">How can i escape double quotes from a string in php?</a>, 
  <a href="https://stackoverflow.com/questions/6627971/mysql-real-escape-string-not-adding-slashes">MySQL_real_escape_string not adding slashes?</a>, 
  <a href="https://stackoverflow.com/questions/7178399/remove-escape-sequences-from-string-in-php">remove escape sequences from string in php</a> I could go on but I am sure you get the point. This is not laziness.</p>