ConFoo Montreal 2026: Call for Papers

Voting

: min(five, seven)?
(Example: nine)

The Note You're Voting On

davidhcefx
4 years ago
As already pointed out by some folks, DON'T PASS ARRAYS KEYED WITH NAMES TO QUESTION MARK PARAMETERS!

<?php
$sth
= $dbh->prepare('INSERT INTO fruit (name, colour, colories) VALUES (?, ?, ?)');

// This is wrong!
// $param = array("name" => "apple", "colour" => "red", "colories" => 150);

// Array must be keyed with integers starting from zero
$param = array("apple", "red", 150);
$sth->execute($param);

<< Back to user notes page

To Top