My code returns the following error:
Parse error: syntax error, unexpected T_VARIABLE in /home/a2015539/public_html/envio.php on line 28
The code is this:
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO cadastro (nome, sexo, dia, mes, ano)
VALUES ('"$nome"','"$sexo"','"$dia"','"$mes"','"$ano"')";
if ($conn->query($sql) === TRUE) {
echo "<script type= 'text/javascript'>alert('New record created successfully');</script>";
} else {
echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";
}
$conn->close();
}