Hello, I have a bug here! I have the same code as another page but this page works and in this one ...
error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Wrong code:
<?php
session_start();
if (empty($_SESSION['u_id'])){
header("Location:../principal.php");
exit(0);
}
require'dbh.inc.php';
$nome=$_POST['Nome'];
$calorias=$_POST['calorias'];
$query=mysqli_query($conn,"INSERT INTO ingredientes (Nome, calorias) VALUES ('$nome','$calorias'") or die(mysqli_error($conn));
mysqli_close($conn);
header("location:../calorias.php?note=success");
page that is linked to this code:
<?php
include("includes/dbh.inc.php");
$note="";
if (!empty($_GET['note'])){
$note=$_GET['note'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calorias</title>
<link href="../css/bootstrap.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../css/estilox.css">
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/calorias.css">
<link rel="stylesheet" type="text/css" href="../css/login.css">
</head>
<body>
<div class="row">
<?php
include 'menu.php';
?>
</div>
<div id="page-wrap">
<?PHP if($note=='success')
{
$msgconfirm='\nCalorias enviadas com Sucesso!';
echo "<script>alert(\"$msgconfirm\")</script>";
}
?>
<div class="container">
<div class="row" id="h-row">
<div class="col-md-12 col-xs-12" id="">
<form class="email-form" method="post" action="includes/sendcalorias.php">
<div class="espaco">
<label for="Nome" class="textoform">Titulo Receita:</label>
<input placeholder="Titulo Receita" class="form" id="titulo" type="text" name="Nome" required="required"/>
</div>
<div class="espaco">
<label for="calorias" class="textoform">Calorias Receita:</label>
<textarea name="calorias" id="message" class="form descricao" placeholder="Calorias Receita" required="required"></textarea>
</div>
<div class="relative fullwidth">
<button type="submit" id="submit" name="submit" class="contact2 form-btn semibold">Enviar Receita</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/bootstrap.js"></script>
<script src="../js/codigo.js" type="text/javascript"></script>
<script src="../js/menu.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/login.js" ></script>
</body>
</html>
Only those pages that are wrong, the other does not!