Error displaying image inside a td in php

0

I am creating a panel and I make a calculation of the time that an OS is open and depending on the result shows a colored ball on the table ... it just does not work when executing this error:

  

Parse error: syntax error, unexpected 'src' (T_STRING), expecting ','   or in C: \ xampp \ htdocs \ panelti \ ti.php on line 177

I'd like you to look at my code too, because it might also be with some error without being that.

<body>
<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
       <a class="navbar-brand" href="index.php">Tecnologia | </a>  
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
      <ul class="nav navbar-nav">
        <li class="active"><a href="index.php"> Home <span class="sr-only">(current)</span></a></li>
        <li ><a href="ti.php">TI</a></li>
        <li ><a href="eletrica.php">ELETRICA</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="http://192.168.0.20/bigwiki/index.php" ><span class="glyphicon glyphicon-globe" aria-hidden="true">BigWiki</a></li>
      </ul>
    </div>
  </div>
</nav>


<?php
$query_pesquisa = mysql_query(" SELECT 
    o.numero AS CHAMADO,
    p.problema AS PROBLEMA,
    o.descricao AS DESCRICAO,
    o.contato AS CONTATO,
    o.telefone AS TELEFONE,
    o.data_abertura AS DATA_ABERTURA,
    i.inst_nome AS UNIDADE,
    a.sistema AS AREA,
    l.local AS SETOR,
    u.nome AS TECNICO,
    ua.nome AS ABERTO_POR,
    s.status AS STATUS,
    sls.slas_tempo AS TEMPO_DE_SOLUCAO
FROM
    ocorrencias AS o
        LEFT JOIN
    sistemas AS a ON a.sis_id = o.sistema
        LEFT JOIN
    localizacao AS l ON l.loc_id = o.local
        LEFT JOIN
    instituicao AS i ON i.inst_cod = o.instituicao
        LEFT JOIN
    usuarios AS u ON u.user_id = o.operador
        LEFT JOIN
    usuarios AS ua ON ua.user_id = o.aberto_por
        LEFT JOIN
    'status' AS s ON s.stat_id = o.status
        LEFT JOIN
    status_categ AS stc ON stc.stc_cod = s.stat_cat
        LEFT JOIN
    problemas AS p ON p.prob_id = o.problema
        LEFT JOIN
    sla_solucao AS sls ON sls.slas_cod = p.prob_sla
        LEFT JOIN
    prioridades AS pr ON pr.prior_cod = l.loc_prior
        LEFT JOIN
    sla_solucao AS slr ON slr.slas_cod = pr.prior_sla
        LEFT JOIN
    script_solution AS sol ON sol.script_cod = o.oco_script_sol
        LEFT JOIN
    prior_atend AS prioridade_atendimento ON prioridade_atendimento.pr_cod = o.oco_prior
WHERE
        a.sistema = 'Ti'
        AND s.status = 'Em Atendimento'
        AND o.status IN (1 , 2,
        3,
        4,
        7,
        12,
        15,
        16,
        19,
        21,
        22,
        28,
        29,
        25,
        26,
        27,
        28,
        29,
        30,
        31)
ORDER BY numero DESC")or die(mysql_error());

    if (empty($query_pesquisa)) {
    echo "Nenhum registro encontrado.";
    }
    ?>
<table class='datatable table table-hover table-bordered table-responsiv'>
   <thead>
     <tr>
        <th>CHAMADO</th>
        <th>PROBLEMA</th>
        <th>DESCRICAO</th>
        <th>CONTATO</th>
        <th>TELEFONE</th>
        <th>DATA</th>
        <th>UNIDADE</th>
        <th>AREA</th>
        <th>SETOR</th>
        <th>TECNICO</th>
        <th>ABERTO</th>
        <th>STATUS</th>
        <th>SOLUCAO</th>
        <th>FAROL</th>
     </tr>
    </thead>
    <?php
       echo"<tbody>";       
     while ($row = mysql_fetch_array($query_pesquisa)) {

     $DATAATUAL = date(Y-m-d);
     $DATAABERTURA = $row['DATA_ABERTURA']; //tem que estar no mesmo formato do de cima. Ex: AAAA-MM-DD
     // Usa a função strtotime() e pega o timestamp das duas datas:
     $time_inicial = strtotime($DATAABERTURA);
     $time_final = strtotime($DATAATUAL);
     // Calcula a diferença de segundos entre as duas datas:
     $diferenca = $time_final - $time_inicial; // 19522800 segundos
     // Calcula a diferença de dias
      $dias = (int)floor( $diferenca / (60 * 24)); // 225 dias
     // Exibe uma mensagem de resultado:
     echo "A diferença entre as datas ".$DATAABERTURA." e ".$DATAATUAL." é de <strong>".$dias."</strong> dias";
     // ente o 60 e 24 use *
     echo" <tr>";
        echo"<td>".$row['CHAMADO']."</td>";
        echo"<td>".$row['PROBLEMA']."</td>";
        echo"<td>".$row['DESCRICAO']."</td>";
        echo"<td>".$row['CONTATO']."</td>";
        echo"<td>".$row['TELEFONE']."</td>";
        echo"<td>".$row['DATA_ABERTURA']."</td>";
        echo"<td>".$row['UNIDADE']."</td>";
        echo"<td>".$row['AREA']."</td>";
        echo"<td>".$row['SETOR']."</td>";
        echo"<td>".$row['TECNICO']."</td>";
        echo"<td>".$row['ABERTO_POR']."</td>";
        echo"<td>".$row['STATUS']."</td>";
        echo"<td>".$row['TEMPO_DE_SOLUCAO']."</td>";
         if($dias == 1) { 
        echo "<td>"<img src='img/verde.png'>"</td>" }
     elseif($dias == 2) { 
        echo "<td>"<img src='img/amarelo.png'>"</td>" }
     elseif($dias == 3) { 
        echo "<td>"<img src='img/vermelho.png'>"</td>" }
       else{ 
        echo "<td>"<img src='img/vazio.png'>"</td>" };
     echo" </tr>";

     }   
  echo"  </tbody>";
 echo" </table>";

?>
<script type="text/javascript"> 
        $(document).ready(function() {
            $('.datatable').dataTable({
                "sPaginationType": "bs_full"
            }); 
            $('.datatable').each(function(){
                var datatable = $(this);
                // SEARCH - Add the placeholder for Search and Turn this into in-line form control
                var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
                search_input.attr('placeholder', 'Search');
                search_input.addClass('form-control input-sm');
                // LENGTH - Inline-Form control
                var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
                length_sel.addClass('form-control input-sm');
            });
        });

        </script>    

</body>
</html>

Att,

Otácio Barbosa

    
asked by anonymous 22.01.2016 / 22:33

1 answer

0

No if($dias == 1) are left over by some double quotation marks in your code. Change the following snippet:

if($dias == 1) { 
        echo "<td><img src='img/verde.png'></td>"; 
     } elseif($dias == 2) { 
        echo "<td><img src='img/amarelo.png'></td>"; 
     } elseif($dias == 3) { 
        echo "<td><img src='img/vermelho.png'></td>";
     } else{ 
        echo "<td><img src='img/vazio.png'></td>";
     };

Note: I initially said that there was a need to escape the apostrophe, but this is not necessary in double quotation marks.

    
22.01.2016 / 22:42