How to remove Parse error: syntax error, Unexpected 'public'

Asked

Viewed 318 times

0

Hello I would like to know how to get this error out of my query

inserir a descrição da imagem aqui

          <?php



          public    function RetornaAtualizacoes(){

        if($_SERVER['REQUEST_METHOD'] == 'POST') {

    try {
        $Query = "SELECT 
                s.setor,
                s.usuario,
                s.hd,
                s.memoria,
                s.cd,
                s.placam,
                s.host,
                s.monitor,
                s.nobreak,
                s.placar,
                s.placav
        FROM setor

                  ";
        include_once $_SESSION['pmodel'].'Projetos/index.php';
               $p_sql = MysqlConnection::getInstance()->prepare($Query);

                $_retorno = array(); 

                if($p_sql->execute()) {
                    while ($_result = $p_sql->fetch(PDO::FETCH_ASSOC))  {
                        $_retorno[] = $_result; 
                    }
                }

                return $_retorno;
            } catch (PDOException $e) {
                echo $e->getMessage();
            }
        }


            }
        ?>


             <div>
                <table width="100%" CELLSPACING="0" CELLPADDING="2" BORDER="1" class='tabelaProt'>
                                <thead>
                                        <tr>
                                             <th>Setor</th>
                                             <th>Usuário</th>
                                             <th>Hd</th>
                                             <th>Memória</th>
                                             <th>Processador</th>
                                             <th>Cd/Dvd</th>
                                             <th>Hd</th>
                                             <th>Memória</th>
                                             <th>Setor</th>
                                             <th>Usuário</th>
                                             <th>Hd</th>
                                             <th>Memória</th>
                                        </tr>
                                </thead>
                        <tbody>         
  <?php
               $setor=$_POST['setor'];
                $usuario=$_POST['usuario'];
                $hd=$_POST['hd'];
                $memoria=$_POST['memoria'];
                $processador=$_POST['processador'];
                $cd=$_POST['cd'];
                $placam=$_POST['placam'];
                $host=$_POST['host'];
                $monitor=$_POST['monitor'];
                $nobreak=$_POST['nobreak'];
                $placar=$_POST['placar'];
                $placav=$_POST['placav'];

         $data           = $_POST["data"];
        $codusuario     = $_POST["codusuario"];
        $cRelatorios = new cRelatorios();
          $relatorio = $cRelatorios->RetornaAtualizacoes();    

                   if(!empty($relatorio)){

                   foreach($relatorio as  $value){
              // echo "<pre>"; print_r($value); exit;
                 echo "<tr>";
                 echo "<td><center>". $value[""] ."</center></td>";
                 echo "<td><center>". $value[""] ."</center></td>";
                 echo "<td><center>". $value[""] ."</center></td>";
                echo "<td>". $value[""] ."</td>";
                echo "<td>". $value[""] ."</td>";
               echo count($relatorio);//Quero que imprima só uma vez dentro do <td>
               echo "</tr >";

                                   }
    }


     ?>
  • How do you feel about removing the public from the function?

  • would just get Function @Acklay

  • when I shoot appears Fatal error: Uncaught Error: Class 'cRelatorios' not found in C: @Acklay

  • I pulled out and appeared Fatal error: Uncaught Error: Class 'cRelatorios' not found in C: @Miguel tried everything and nothing

  • You have to take the public anyway, this error there of class cRelatorios not found is because you forgot to import it, or does it really exist? In future issues do not post the error print, just copy and paste the text here, it is much easier to read on some devices or someone copy on google to help you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.