News for hackers. Stuff that matters.
Re:PHP the Wrong Way by iopq on Friday August 19, 2016 @07:40AM (#12319344)
They removed mysql_real_escape_string function so that you can use mysqli_real_escape_string http://php.net/manual/en/mysqli.real-escape-string.php
Re:PHP the Wrong Way by greyman on Friday August 19, 2016 @08:44AM (#12319602)
No, you use PDO::quote().
Re:PHP the Wrong Way by CiPHPerCoder on Friday August 19, 2016 @10:07AM (#12320081)
No, you use

  $pdo->prepare("SELECT id FROM foo WHERE bar = ? AND baz = ?")
      ->execute([$baz, $qux]);
...while taking care to set PDO::ATTR_MODE to PDO::ERRMODE_EXCEPTION and PDO::ATTR_EMULATE_PREPARES to false when your PDO object is initialized.

https://github.com/paragonie/airship/blob/8b7edde11b5b57fcb4...

See also: http://stackoverflow.com/a/12118602/2224584

Re:PHP the Wrong Way by roblabla on Friday August 19, 2016 @11:22AM (#12320650)
This is the problem I have with PHP. 15 ways to do something seemingly simple, and only one obscure way is correct (What's PDO::ATTR_MODE ?) And why does PDO try to emulate prepares ?
Re:PHP the Wrong Way by stephenr on Friday August 19, 2016 @12:17PM (#12321135)
That was 4 ways. The documentation identify what the options do.
Re:PHP the Wrong Way by stephenr on Friday August 19, 2016 @12:16PM (#12321120)
Named parameters are much simpler to use IMO.
Re:PHP the Wrong Way by CiPHPerCoder on Friday August 19, 2016 @12:27PM (#12321224)
Simpler? No. Easier? Yes.