0

I have an error like

Type: ParseError

Message: syntax error, unexpected '.'

Filename: /opt/lampp/htdocs/cctv/application/views/edit_camera.php

where's my error?

<div style="margin-top: " class="form-group">
  <label>Terminal</label>
  <select class="form-control input-lg" id="required" name='id_terminal' data-placeholder="Pilih transaksi">
   <?php foreach ($get_camera as $cam) { 
     if ($cam->id_camera == $this->uri->segment(3)) {
       foreach ($terminal as $ter) { 
         if($ter->id_terminal == $cam->id_terminal) { ?>
           <?php echo "<option ".($cam->id_terminal == $ter->id_terminal ? ." selected='selected'".).">".$ter->nama_terminal."</option>" ?>
        <?php   }
       }
     } ?>
   <?php } ?>
  </select>
</div>
Nico Haase
  • 11,420
  • 35
  • 43
  • 69
Rizky Alviandra
  • 31
  • 1
  • 13
  • 3
    It would help if you had said which is line 70, but I think it's the `.`. in `id_terminal ? ." selected` (after the ?) – Nigel Ren Aug 21 '18 at 07:34
  • 2
    Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Nigel Ren Aug 21 '18 at 07:34

2 Answers2

0

This line

<?php echo "<option ".($cam->id_terminal == $ter->id_terminal ? ." selected='selected'".).">".$ter->nama_terminal."</option>" ?>

should be changed to

<?php echo "<option ".($cam->id_terminal == $ter->id_terminal ? " selected='selected'" : '').">".$ter->nama_terminal."</option>" ?>

You have simply added too much "." for string concatenation, and missed the ":" on the ternary operator.

Lorenzo S
  • 1,397
  • 13
  • 25
0

You should try this way, there is issue with the way you concatenat string :

<div style="margin-top: " class="form-group">
    <label>Terminal</label>
    <select class="form-control input-lg" id="required" name='id_terminal' data-placeholder="Pilih transaksi">
    <?php 
        foreach ($get_camera as $cam) { 
            if ($cam->id_camera == $this->uri->segment(3)) {
                foreach ($terminal as $ter) { 
                    if($ter->id_terminal == $cam->id_terminal) {
                        echo "<option ".($cam->id_terminal == $ter->id_terminal ? " selected='selected'":'').">".$ter->nama_terminal."</option>";
                     }
                }
            } 
        } 
    ?>
    </select>
</div>
Yogesh Salvi
  • 1,177
  • 2
  • 10
  • 17