1
I am trying to enter a record in the bank using this code:
$sql = "INSERT INTO tb_ConteudoExtra
(Titulo_ConteudoExtra, Texto, Id_TipoConteudoExtra, Data, Hora)
VALUES
('".$nomePagina."', '".$html."','0','".$data."','".$hora."')";
$sql = $this->db->prepare($sql);
$execute = $sql->execute();
If I give a var_dump
in the $execute
it will show that the return was TRUE, but when I will look at the bank table, nothing was inserted.
The first thing I did, was to print the variable $sql
and try to run straight into the bank to find out the error, only it had no error, successfully inserts.
INSERT INTO tb_ConteudoExtra
(Titulo_ConteudoExtra, Texto, Id_TipoConteudoExtra, Data, Hora)
VALUES
('teste dois', '<html>
<head>
<title></title>
</head>
<body>
<p>teste de conteudo dentro do CKEDITOR</p>
</body>
</html>
','0','05/02/2019','15:28:36')
I tried to find a solution, but I couldn’t find anything that helped me.
@EDIT I tested it that way too and it’s still the same:
$sql = "INSERT INTO tb_ConteudoExtra(Titulo_ConteudoExtra, Texto, Id_TipoConteudoExtra, Data, Hora)
VALUES
(':nomepagina', ':html','0',':data',':hora')";
$sql = $this->db->prepare($sql);
$sql->bindValue(":nomepagina",$nomePagina);
$sql->bindValue(":html",$html);
$sql->bindValue(":data",$data);
$sql->bindValue(":hora",$hora);
$execute = $sql->execute();
Have you seen if the autocommit is on? playing the values directly in the query you throw away the benefit of prepare query.
– rray
@rray I tested using the bindValue too, but gave in the same
– Otavio Souza Rocha
@rray I edited there to show how I did with bindValue
– Otavio Souza Rocha