Reputation: 137
mySQL query error: SELECT hash('SHA512', ( CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) as word_lookup, word_id, hash('SHA512', word_default) as word_default, word_default_version FROM forum_core_sys_lang_words WHERE word_app='core' AND lang_id IN(1)
SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('SHA512', ( CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) a' at line 1
SQL error code: 1064
Date: Thursday 18th July 2013 03:34:35 PM
I am using IPBoard forums, and I decided to not use MD5, and use SHA512 instead.
I am using notepad++, so I just renamed ALL md5(
with hash('SHA512',
.
And after installation, I get this SQL error.
Does that mean that SQL query doesn't support hash()? How can I fix it?
$this->DB->build( array( 'select' => "hash('SHA512', ( CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) as word_lookup, word_id, hash('SHA512', word_default) as word_default, word_default_version",
'from' => 'core_sys_lang_words',
'where' => "word_app='{$app_override}' AND lang_id IN(" . implode( ",", $lang_ids ) . ")" ) );
$this->DB->execute();
Upvotes: 2
Views: 248
Reputation: 461
The hash functions in MySQL are SHA1 and SHA2. You can refer the MySQL documentation for the proper syntax(https://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html#function_sha2)
In your case the code should be
$this->DB->build( array(
'select' => "SHA2(CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ), 512) AS word_lookup, word_id, SHA2(word_default, 512) AS word_default, word_default_version",
'from' => 'core_sys_lang_words',
'where' => "word_app='{$app_override}' AND lang_id IN(" . implode( ",", $lang_ids ) . ")"
));
SHA2 is only available in MySQL versions 5.5.5 and above. Alternatively you can use the old SHA1 function but here you cannot control the bit length.
Upvotes: 1
Reputation: 1819
Change this:
SELECT hash('SHA512', ( CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) as word_lookup
to this:
SELECT hash('SHA512', CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) as word_lookup
Upvotes: 0