I have this code for encrypting the ID of every row:
class publicfunction {
public static function EncryptString($input) {
$Key = "KEY_GOES_HERE";
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $Key, $input, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}
}
// I skipped the code for read the mysql
while($fetch = mysqli_fetch_array($r)) {
$ProductID = $fetch[0];
print "<a href='mstpublc.php?id=" . publicfunction::EncryptString($ProductID) . "'>Edit </a>";
}
There are more than 1 data on the $fetch but it only return 1 row. What’s wrong with the code? But when I omit the EncryptString function on the while section, it returns all the value on the $fetch. FYI, while in localhost, it works well, but when I uploaded the code, it doesn’t work.
The problem was solved by installing the mcrypt on the live server. Thanks all 🙂