Incorrect bind column causes HY093
Over the past few weeks, I’ve been learning more about XSL, Javascript, and CSS. Along the way, I’ve been doing much more work with PDO. Yesterday I encountered a 501: Internal Server Error which had me stumped until this morning.
The SQL was something like this:
INSERT INTO mybconfig.keys (key_name, key_type_id) VALUES ( :key_name, :key_id_type )’
Upon calling execute(), the exception thrown was similar to this:
501: Internal Server Error
Description: The server encountered an internal error or misconfiguration and was unable to complete your request.
Message: HY093: SQL: INSERT INTO mybconfig.keys (key_name, key_type_id) VALUES ( :key_name, :key_id_type )
The code looked like this (greatly simplified for demonstration purposes):
$query = $this->tPDO->prepare('INSERT INTO keys (key_name, key_type_id) VALUES ( :key_name, :key_id_type )');
$query->bindValue( ':key_name', 'testing');
$query->bindValue( ':key_type_id', 1);
Look for a while, then find the problem. I know the cause, and will update this post with the solution.

April 1st, 2009 at 11:54 am
“key_type_id” vs “key_id_type”
October 2nd, 2009 at 7:47 am
Ron: Yes, that’s the issue.
I encountered this same problem yesterday. I mentioned it to my DBA. He didn’t recognize the error code.
He went searching for it, and found this article.