Error - Parse error: syntax error, Unexpected '[' in

Asked

Viewed 57 times

-2

There’s a syntax error on line 13, you could help me decipher, I’m not finding.

OBS: in localhost it works, but in server web displays the error.

<!--Início Scritp PHP-->
<?php
    session_start();
    include_once 'conexao.php';
    $nome     = filter_input (INPUT_POST, 'nome', FILTER_SANITIZE_SPECIAL_CHARS);
    $empresa  = filter_input (INPUT_POST, 'empresa', FILTER_SANITIZE_SPECIAL_CHARS);
    $telefone = filter_input (INPUT_POST, 'telefone', FILTER_SANITIZE_NUMBER_INT);
    $email    = filter_input (INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
    $endereco = filter_input (INPUT_POST, 'endereco', FILTER_SANITIZE_SPECIAL_CHARS);
    $cnpj     = filter_input (INPUT_POST, 'cnpj', FILTER_SANITIZE_SPECIAL_CHARS);
    $obs      = filter_input (INPUT_POST, 'obs', FILTER_SANITIZE_SPECIAL_CHARS);
    $querySelect = $link->query("select email from tb_clientes");
    $array_emails = []; **<- esta linha**
    while($emails = $querySelect->fetch_assoc()):
        $emails_existentes = $emails['email'];
        array_push($array_emails,$emails_existentes);
    endwhile;
    if(in_array($email,$array_emails)):
        $_SESSION['msg'] = "<p class='center red-text'>".'Já existe um cliente cadastrado com esse E-mail!'."</p>";
        header("Location: cadastro.php");
        else:
        $queryInsert = $link->query("insert into tb_clientes values (default,'$nome','$empresa','$telefone','$email','$endereco','$cnpj','$obs')");
        $affected_rows = mysqli_affected_rows($link);
        if($affected_rows > 0):
            $_SESSION['msg'] = "<p class='center green-text'>".'Cadastro efetuado com sucesso!'."</p>";
            header("Location: cadastro.php");
        endif;
    endif;
?>
<!--Fim Scritp PHP-->
  • The notation of array square-bracketed, [], only added in version 5.4. What is the PHP version of your server?

  • Good morning, thanks for the quick reply, she was in 5.2, I switched to 5.6 for testing and appeared three more errors, I tested in 7.0 and also gave the three errors.

  • 1

    If you go to a lodging house, mostly you pay, just run. There is no justification for having such an obsolete PHP, the excuse of "compatibility with what is running" (in the case of "professional" hosting) actually translates to "I have no competence to work with server administration". It scares me to know that there is an easy place to download these versions.

  • @Bacco - Yes it is paid accommodation, it comes as standard in 5.2, and yes I have no competence to work because it is the first time I am doing this, even researching, because your had competence would not be asking and asking for help.

  • 1

    @Rodrigobernardovieira did not say about his competence, said the hosting staff, who should have an obligation to look after the system upgrade (unless you voluntarily request a legacy system knowing you have security issues). Your role is to develop, and you pay them to keep something in order for you, so I understand that the provision of service is leaving you wanting.

  • @Bacco - Opa so I apologize I misinterpreted your comment, I thought it was directed to me, a thousand apologies again.

  • @Rodrigobernardovieira does not need to apologize, I’m worried that I sounded offensive without the intention.

  • 1

    Also because, it was a vent because I see a lot of this happening, and look that there are some "famous" names in the market that make this madness. However, as you have already read the recommendation, I will delete my comments in a few minutes to not leave mess here in your post.

  • @Bacco No problem, thank you we are together...

  • Thank you all for your help!!!

Show 5 more comments

1 answer

0


  • 2

    I think the viable alternative would be to update PHP even xD

  • I got an error similar to this one and ended up doing it to solve this problem. I am using Windows.

  • 1

    If it is an application limitation to have to use an outdated version, yes, it would be a solution. If not, there is no justification for not updating the language and enjoying all the improvements.

  • Yes, that’s right. I agree that the best alternative is to update your PHP.

  • Good morning, thanks for the answers, she was in 5.2, I switched to 5.6 for testing and appeared three more errors, I tested in 7.0 and also gave the three errors.

  • What would be these mistakes?

  • 1st error Warning: session_start(): Cannot send Session cache Limiter - headers already sent (output Started at /home2/rcbwde18/public_html/sistema_rcbwdesign/client/create.php:2) in /home2/rcbwde18/public_html/sistema_rcbwdesign/client/create.php on line 3

  • 2nd error Warning: Cannot Modify header information - headers already sent by (output Started at /home2/rcbwde18/public_html/sistema_rcbwdesign/client/create.php:2) in /home2/rcbwde18/public_html/sistema_rcbwdesign/client/conexao.php on line 2

  • connection.php <? php $utf8 = header("Content-Tyoe:text/html; charset=utf-8"); $link=new mysqli('localhost','rcbwde18_rcbwd19','AU[3,YGE! yn','rcbwde18_db_cadastro_01'); $link->set_charset('utf8'); ?>

  • 3rd error Warning: Cannot Modify header information - headers already sent by (output Started at /home2/rcbwde18/public_html/sistema_rcbwdesign/client/create.php:2) in /home2/rcbwde18/public_html/sistema_rcbwdesign/client/create.php on line 20

  • These errors are pq vc sending things like this here to HTML before PHP <!--Início Scritp PHP--> If you search for the error message right here, you will find a good explanation of what happens: https://answall.com/search?q=Cannot+modify+header+information

  • @Bacco - dude thanks, I took <!-Home Scritp PHP->, and it worked Perfect!!! , thank you.

Show 7 more comments

Browser other questions tagged

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