-1

Here's my SQL statement:

protected static $_SQLInsert = "INSERT INTO location
(host_id, street, suburb, region, post_code, country, phone, email,
timezone, longitude, latitude, is_main)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

I prepare the statement as follows:

static::$_PDOSInsert = self::$_PDO->prepare(static::$_SQLInsert);

After preparing an array with 12 values, I execute the statement with:

static::$_PDOSInsert->execute($array);

I then get the following warning:

PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in...

So, what am I doing wrong???

EDIT: Here's the array:

(
    [host_id] => 15
    [street] => Street 15
    [suburb] => Suburb 15
    [region] => Region 15
    [post_code] => Post Code 15
    [country] => AU
    [phone] => 12341234
    [email] => asfd@email.com
    [timezone] => 1
    [longitude] => 123
    [latitude] => 234
    [is_main] => 1
)

Thanks!

DatsunBing
  • 8,684
  • 17
  • 87
  • 172

1 Answers1

2

pdo is really picky about the array you give to execute(). If you used unnamed placeholders like ?, it wants a numerically indexed array, and it must start at index 0.

goat
  • 31,486
  • 7
  • 73
  • 96