this giving error Parse error: syntax error, Unexpected $end in /home/Kleber/public_html/adds-product.php on line 24

Asked

Viewed 47 times

0

<?php include("cabecalho.php")?>
<?php
 $nome= $_GET["nome"];
 $preco= $_GET["preco"];
 $servername = "localhost";
 $username = "";
 $password = "";
 $dbname = "";
 $conexao = new mysqli($servername, $username, $password, $dbname);
 $query = "insert into Produtos (nome,preco) values('$nome',$preco)";
 if(mysqli_query($conexao,$query))
{
?> <p class="alert-success"> produto <?php echo $nome ?> adicionado com sucesso! Preco <?php echo $preco ?></p>
}
else
{
?>
<p class="alert-danger"> produto <?php echo $nome ?> nao foi adicionado  Preco <?php echo $preco ?></p>
}

<?php
 mysqli_close($conexao);
 ?>
 <?php include("rodape.php")?>

1 answer

1


It’s boring but you have to open php tags to close the braces

...

?>
    <p class="alert-success"> produto <?php echo $nome ?> adicionado com sucesso! Preco <?php echo $preco ?></p>
<?php }
else
{ ?>
    <p class="alert-danger"> produto <?php echo $nome ?> nao foi adicionado  Preco <?php echo $preco ?></p>
<?php }
mysqli_close($conexao);
include("rodape.php");
?>

Browser other questions tagged

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