我想使用select aes(pertanyaan, 'bangsat12') from table
显示解密的文本表单数据库,但是我有这样的输出
语法错误,意外的“ bangsat12”(T_STRING)
我正在使用,现在是localhost,并且是php5.6(xampp)
我的代码是这样的。
<?php
$query = $this->db->query('SELECT nomer_soal, aes_decrypt(pertanyaan,'bangsat12'), jawaban_1, jawaban_2, jawaban_3, jawaban_4 from soal');
foreach ($query->result_array() as $row){
$nomer_soal = $row['nomer_soal'];
$pertanyaan = $row['pertanyaan'];
$a = $row['jawaban_1'];
$b = $row['jawaban_2'];
$c = $row['jawaban_3'];
$d = $row['jawaban_4'];
?>
<tr>
<td><?php echo $nomer_soal; ?></td>
<td><?php echo $pertanyaan; ?></td>
<td><?php echo $a; ?></td>
<td><?php echo $b; ?></td>
<td><?php echo $c; ?></td>
<td><?php echo $d; ?></td>
</tr>
<?php
}
?>
答案 0 :(得分:0)
您的外部字符串引号会被sql查询中的引号打断。试试
$query = $this->db->query("SELECT nomer_soal, aes_decrypt(pertanyaan,'bangsat12'), jawaban_1, jawaban_2, jawaban_3, jawaban_4 from soal");
(我将外部的'替换为',也可以将'用作外部字符串,并在查询本身中使用')