i want to show decrypted text form database using select aes(pertanyaan, 'bangsat12') from table but i have output like this

syntax error, unexpected 'bangsat12' (T_STRING)

im use, localhost for now, and php5.6 (xampp)

my code like this.

<?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 
    } 
?>

1 Answers

0
FMK On

Your outer string quotes get interrupted by the quotes in the sql query. Try

$query = $this->db->query("SELECT nomer_soal, aes_decrypt(pertanyaan,'bangsat12'), jawaban_1, jawaban_2, jawaban_3, jawaban_4 from soal");

(I replaced the outer ' with ", you could also use ' for the outer string and " in the query itself)