0

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 
    } 
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
say
  • 23
  • 6

1 Answers1

0

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)

FMK
  • 1,062
  • 1
  • 14
  • 25
  • done, thanks man, you are my hero. after replace that, i replace to, from $pertanyaan = $row['pertanyaan']; to $pertanyaan = $row["aes_decrypt(pertanyaan,'bangsat12')"]; – say May 13 '19 at 08:28
  • No Problem, you could mark my answer as accepted to show the other users that your problem was fixed! – FMK May 13 '19 at 08:29