Reputation: 5941
Why does the following statement fail in php (I have an established PDO connection to sqlite database named config.db).
$stmt = $this->db->prepare("INSERT INTO config (S_BASE_DIR) VALUES (':col0')");
$stmt->bindParam(':col0',$colValue);
$stmt->execute();
$stmt->close();
The exact error is:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 25 bind or column index out of range'
Upvotes: 2
Views: 1529
Reputation: 21866
When binding to a column, you do not need to quote the column:
$stmt = $this->db->prepare( "INSERT INTO config (S_BASE_DIR) VALUES ( :col0 )" );
$stmt->bindParam(':col0', $colValue);
With quotes around the :col0
it is just a string, and not a binding parameter.
Upvotes: 2