-1
I have a code that inserts records into the database, it is not displaying any error, it is simply not sending the data to the database
the code worked previously only that as mysql_* became obsolete I had to update, and then it stopped working
here is the code
<?php
include "../../lib/inc_con.php";
session_start();
$mesa = $_POST['mesa'];
$tamanho = $_POST['tamanho'];
$quantidade = $_POST['qtd'];
$adicional = implode(',', $_POST['adicional']);
$hiddentotal = $_POST['hiddentotal'];
date_default_timezone_set('America/Sao_Paulo');
$mysqldata = new DateTime();
$data = $mysqldata->format(DateTime::ISO8601);
$produto_id1 = utf8_encode($_POST['produto_id1']);
$atendente_id = $_SESSION['id'];
$observacao = $_POST['observacao'];
$produzido = '0';
$valortotal = $quantidade * $hiddentotal;
$asplo = $_POST['asplo'];
$inserir = $conexao->query("INSERT INTO pedidos (mesa, tamanho, qtd, adicional, valortotal, data, produto_id1, atendente_id, produzido, observacao, asplo)
values ('$mesa', '$tamanho', '$quantidade', '$adicional', '$valortotal', '$data', '$produto_id1', '$atendente_id', '$produzido', '$observacao', '$asplo'") or die (mysqli_error());
if($inserir){
echo "Inserido";
} else {
echo $inserir->error;
}
?>
inc_cong.php file
<?php
error_reporting(0);
ini_set(“display_errors”, 0 );
$hostname = "localhost";
$username = "root";
$password = "";
$dbdatabase = "moclient";
$conexao = new mysqli($hostname, $username, $password, $dbdatabase);
if($conexao->connect_error){
echo "Conexao:";?><span class="ls-tag-danger">Erro!</span>
<?php
}else{
echo "Conexao:";?><span class="ls-tag-success">OK!</span>
<?php }
?>
If you echo var $insert or copy the query and echo the query and directly test it performs the Insert?
– Doug
Post the contents of
inc_con.php
.– Guilherme Nascimento
<?php error_reporting(0); ini_set("display_errors", 0 ); $hostname = "localhost"; $username = "root"; $password = ""; $dbdatabase = "moclient"; $connected = new mysqli($hostname, $username, $password, $dbdatabase); if($connect_error){ echo "Connected:";? ><span class="ls-tag-Danger">Error! </span> <? php }Else{ echo "Connected:";? ><span class="ls-tag-Success">OK! </span> <? php } ?>
– Alfredo Lima
Although it is not returning errors, it even returns some message ?
– Edilson
Return Connection: OK!
– Alfredo Lima
I’m talking about this condition here
if($inserir)
, returns inserted ? Or returns the error ?– Edilson
Returns nothing
– Alfredo Lima
Alfredo, it would be nice if we had a crystal ball to guess what’s going on. but we don’t.. That’s why there’s such a "feedback".. vc just returns vague things... If you want help, help us help you. but be aware that this is not a support and help center. Your job is your responsibility.
– Daniel Omine
@Alfredolima made the changes as I suggested in my reply http://answall.com/a/95832/3635 ?
– Guilherme Nascimento