-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?– Woss
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.
– Rodrigo Bernardo Vieira
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
@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.
– Rodrigo Bernardo Vieira
@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
@Bacco - Opa so I apologize I misinterpreted your comment, I thought it was directed to me, a thousand apologies again.
– Rodrigo Bernardo Vieira
@Rodrigobernardovieira does not need to apologize, I’m worried that I sounded offensive without the intention.
– Bacco
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
@Bacco No problem, thank you we are together...
– Rodrigo Bernardo Vieira
Thank you all for your help!!!
– Rodrigo Bernardo Vieira