下面的代码在PHP中运行,它将返回空字符串。但是在mysql中运行相同的查询会显示一些值。
<?php
$encrypt_query = "select aes_encrypt('$string','$key') as encrypt_data";
$encrypt_result = mysql_query($encrypt_query);
print_r($encrypt_result);// it returns resource id #7
$row = mysql_fetch_array($encrypt_result);
return $row['encrypt_data'];//it return empty
?>
答案 0 :(得分:1)
尝试
<?php
$encrypt_query = "select aes_encrypt('$string','$key') as encrypt_data";
$encrypt_result = mysql_query($encrypt_query);
print_r($encrypt_result);// it returns resource id #7
while($row = mysql_fetch_array($encrypt_result)){
echo $row['encrypt_data'];
}
?>
//或
$row = mysql_fetch_row($encrypt_result);
echo $row[0];