0
Guys I’m having a problem with this error message,I checked the connection to the database and sure I can register but when it comes time to update it of this error and I can’t find out
Follow the update code:
?php
include "conexao.php";
if(!empty($_POST)){
$id = (isset($_POST['id'])) ? $id = $_POST['id'] : mysqli_close($conect);
$cpf = (isset($_POST['cpf'])) ? $cpf = $_POST['cpf'] : mysqli_close($conect);
$nome = (isset($_POST['nome'])) ? $nome = $_POST['nome'] : mysqli_close($conect);
$email = (isset($_POST['email'])) ? $email = $_POST['email'] : mysqli_close($conect);
$telefone = (isset($_POST['telefone'])) ? $telefone = $_POST['telefone'] : mysqli_close($conect);
$sql = "UPDATE cadastro SET cpf = '$cpf',nome = '$nome',email = '$email',telefone = '$telefone'
WHERE id = '$id' ";
$query = mysqli_query($conect,$sql);
var_dump($id);
var_dump($cpf);
var_dump($nome);
var_dump($email);
var_dump($telefone);
}
else{
header("Location:cadastro.php");
}
?>
Follows the connection:
<?php
$host = "localhost";
$user = "root";
$psw= "";
$db = "exercicio";
$conect = mysqli_connect($host,$user,$psw,$db);
$charset = mysqli_set_charset($conect,"utf8");
?>
You are using the ternary operator as if it were an `if/Else. It works as an if. It tests a condition (the first operand), if it is true, the result of the operation is the first value (after the ?, the second operand), if it is false, then the result is the second value (after the :, the third operand). Read the reply: https://answall.com/a/56814/137387
– Augusto Vasques