Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No <code>mysql_real_escape_string()</code>! You should use <a href="http://php.net/pdo" rel="nofollow noreferrer">PDO</a>. It uses prepared statements, which will not be vulnerable to injection attacks because MySQL is given the unparameterized SQL first and then given the data to plug in.</p> <p>For example:</p> <pre><code>$dbh = new PDO(); $stmt = $dbh-&gt;prepare('INSERT INTO data (something) VALUE(:userInput)'); // No mysql_real_escape_string necessary $stmt-&gt;execute(array( ':userInput' =&gt; $_POST['userInput'] )); </code></pre> <p><code>htmlspecialchars()</code> shouldn't be used on all input, but it should be used! Although typically applied after data is retrieved from the db (although, it might be a good idea to do it before in case it is forgotten afterward), it is useful for user input that you will be echoing into your HTML pages. It protects you against XSS (Cross Site Scripting) attacks, in which a malicious user can add <code>&lt;script&gt;</code> tags that contain malicious code into an input field on your site. When other users visit the page on which this malicious user posted, their browser will interpret the evil scripting, which could do things such as steal session ids or attempt CSRF (Cross Site Request Forgery).</p> <p>Bottom line: You should use it before echoing any user content to your pages. Unless that content has been validated by a rigorous filter (like one for birthdates which only accepts mm/dd/yy). If you're unsure, then use it anyways. It won't hurt. It will only help!</p> <p>Further Reading:</p> <ul> <li><a href="https://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php/60496#60496">How can I prevent SQL injection in PHP?</a></li> <li><a href="https://stackoverflow.com/questions/2905886/what-makes-an-input-vulnerable-to-xss">What makes an input vulnerable to XSS?</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload