I want to search a query in a MySQL table called "keys" based on a key, and then return other values for that query. (e.g. "id")
This is how my table looks like:
id key customer
88633631 gNjp4CW6E/VfdBqli6zBLw== Name1
41317488 bi74frT3LFGTRkvoW7B31Q== Name2
..and this is how my PHP code looks like:
<?php
require 'config.inc.php';
/* Declare variables */
$key = $_GET["key"];
$id = "";
$customer = "";
/* Connect to database and grab the keys */
@mysql_connect($g_mysql_host,$g_mysql_usr,$g_mysql_pass)
or die("Couldn't connect to database server");
@mysql_selectdb($g_mysql_db)
or die("Couldn't select database");
$query = "SELECT * FROM `keys` WHERE `key` = $key";
$result = mysql_query($query);
if (!$result) exit("INVALID KEY");
else {
while ($row = mysql_fetch_array($result)) {
echo $row['id'];
}
}
?>
But this does not work. I think that the problem is caused by the 2 equals at the end of the key, but I'm not sure. If I want to search the "id" and then print the "key" of the searched "id", it works.
I don't want to remove the 2 equals at the end, because they are related to AES128 padding.
Actually, the problem is not caused by the 2 equals at the end of the key. It is caused by the "+" character inside the string, but if I remove it I can't decrypt the AES128 encrypted text.