2
People php is returning that is entering the data but in the database it does not insert:
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$stmt = $conn->prepare("INSERT INTO perguntas (nome, pergunta, resposta1,resposta2,resposta3,respostaCorreta)
VALUES (?,?,?,?,?,?)");
$stmt->bind_param("ssssss",$nomePergunta,$pergunta,$reposta1,$reposta2,$resposta3,$respostaCorreta);
//Pegando dados via post
$nomePergunta = $_POST["nome"];
$pergunta = $_POST["pergunta"];
$resposta1 = $_POST["resposta1"];
$resposta2 = $_POST["resposta2"];
$resposta3 = $_POST["resposta3"];
$respostaCorreta = $_POST["resposta"];
$stmt->execute();
echo "dados inseridos com sucesso";
Tries to change the order $startName = $_POST["name"]; ................. $stmt = $Conn->prepare("INSERT INTO questions (name, question, answer1,answer2,answer3,answerCorrects) VALUES (?,? ,? ,? ,? ,? )"); $stmt->bind_param("ssssss",$nameQuest,$question,$reply1,$reply2,$reply3,$replyCorrects);
– Marcos Vinicius Leão
kkk, the order certainly influences the Insert, but if you don’t put an if no
execute()
, even if for another reason you do not enter will return "successfully entered data";– Vinicius De Jesus
It is not missing to do a query to send to the database?
– riki481
If you take the instruction and run it straight into the database, what error occurs ?
– 8biT