Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在带绑定变量的预处理语句中使用AES_加密_Php_Mysqli_Aes - Fatal编程技术网

Php 在带绑定变量的预处理语句中使用AES_加密

Php 在带绑定变量的预处理语句中使用AES_加密,php,mysqli,aes,Php,Mysqli,Aes,想要加密一个特定的数据变量,但不断得到“PHP致命错误:调用未定义的函数AES_encrypt()…” 研究表明,它使用的是PHP而不是MySQL $key="xyz"; $stmt = mysqli_prepare($mysqli, "INSERT INTO details (FirstName, LastName, EncryptThis) VALUES (?,?,?)"); if ($stmt === false) { trigger_error('Statement

想要加密一个特定的数据变量,但不断得到“PHP致命错误:调用未定义的函数AES_encrypt()…”

研究表明,它使用的是PHP而不是MySQL

$key="xyz";

$stmt = mysqli_prepare($mysqli, "INSERT INTO details (FirstName, LastName, EncryptThis) VALUES (?,?,?)");

if ($stmt === false) {
        trigger_error('Statement failed! ' . htmlspecialchars(mysqli_error($mysqli)), E_USER_ERROR);
    }                      

$bind = mysqli_stmt_bind_param($stmt, "sss", $FirstName, $LastName,  AES_ENCRYPT('$EncryptThis','$key'));

        if ($bind === false) {
        trigger_error('Bind param failed!', E_USER_ERROR);
    }                  

$exec = mysqli_stmt_execute($stmt);
我正在数据库中使用varbinary

试过各种各样的用法

AES_ENCRYPT('$EncryptThis','$key')
乙二醇

etc

MySQL希望将值作为绑定参数传递。不是函数名或其他SQL表达式。只是价值观

如果要调用MySQL AES_ENCRYPT函数,则需要将其显示为SQL文本的一部分(作为SQL语句准备的字符串)。函数名不能作为绑定参数的一部分传递

像这样:

 "INSERT ... VALUES ( ? , ? , AES_ENCRYPT( ? , ? ) )" 

 mysqli_stmt_bind_param($stmt, "ssss", $FirstName, $LastName, $EncryptThis, $key);

Thx@rjdown的可能重复,在研究期间发现了这个…已经更新-没有PHP致命错误,除了DB列中显示的空白值。。错误日志中没有错误。我没有在DB中为$key添加额外的列?插页应该包括钥匙吗?不-都好。我对引用语的使用不当。谢谢@spencer7593
 "INSERT ... VALUES ( ? , ? , AES_ENCRYPT( ? , ? ) )" 

 mysqli_stmt_bind_param($stmt, "ssss", $FirstName, $LastName, $EncryptThis, $key);