php - Mysqli Prepared Statement with AES Encryption -


this question has answer here:

i'm having trouble getting prepared statement select rows database thats using built in aes_encryption. if run query though phpmyadmin, works fine, , returns expected values, running through bind_params returns -1.

returns -1 , no rows

$query = "select `col0`,      cast(aes_decrypt(`col1`, '$this->key') char(50)) col1_decrypt,     cast(aes_decrypt(`col2`, '$this->key') char(50)) col2_decrypt      `$table`  `$field` = aes_encrypt(?, '$this->key')";  // tried in clause. // -- cast(aes_decrypt(`$field`, '$this->key') char(50)) = ?";  if($stmt = $this->db->prepare($query)) {     try {         $stmt->bind_param('s', $incomingfield);     } catch (exception $e) {         // testing         print $this->db->error;     }      $stmt->execute();      if($stmt->num_rows > 0) {         print "found";     } else {         print "not found";     }    

return

(mysqli_stmt)#52 (10) { ["affected_rows"]=> int(-1) ["insert_id"]=> int(0) ["num_rows"]=> int(0)

running normal query:

select `col0`,      cast(aes_decrypt(`col1`, 'secret key') char(50)) col1_decrypt,     cast(aes_decrypt(`col2`, 'secret key') char(50)) col2_decrypt     `tablename`  `field` = aes_encrypt('search value', 'secret key') 

will return row i'm looking for.

stupid question... forgot

$stmt->store_result(); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -