Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is PDO better for escaping MySQL queries/querystrings than mysql_real_escape_string?
    text
    copied!<p>I've been told that I'd be better using <code>PDO</code> for MySQL escaping, rather than <code>mysql_real_escape_string</code>.</p> <p>Maybe I'm having a brain-dead day (or it may be the fact I'm by no stretch of the imagination a natural programmer, and I'm still very much at the newbie stage when it comes to PHP), but having checked out the PHP manual and read <a href="http://www.php.net/manual/en/pdo.prepare.php" rel="noreferrer">the entry on PDO</a>, I'm still no clearer as to what PDO actually is and why it's better than using <code>mysql_real_escape_string</code>. This may be because I've not really got to grips with the complexities of OOP yet (I'm assuming it's something to do with OOP), but other than the fact that variables and array values seem to have a colon infront of them, I'm still not sure what it actually is and how you use it (and why it's better than <code>mysql_real_escape_string</code>. (It also may have something to do with the fact that I don't really have a clear understanding of what 'classes' are, so when I read "PDO class" I'm none the wiser really).</p> <p>Having read <a href="http://dev.mysql.com/tech-resources/articles/mysql-pdo.html" rel="noreferrer">an article</a> or two on the 'Developer Zone' bit of the MySQL website, I'm still no clearer. As I can't even figure out what it is at the moment, I think probably using it is a bit beyond me right now, but I'm still interested in broadening my education and finding out how I could improve things. </p> <p>Could anyone explain to me in 'plain English' what PDO is (or point me in the direction of something on the subject written in plain English), and how you'd go about using it?</p>
 

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