UPDATE mysqli does not work and does not throw error

-1

I have this function that makes an update depending on the variable $ status, what does not work for me is the UPDATE, and it does not throw me any errors, I forgot to put something else?

function setInfoStatusProject($status, $project){
include("bd.php");
session_start();
$idEmp = $_SESSION['id'];
$today = date('Y-m-d');
if($status == 1){
    $query = "UPDATE projectInfo SET closedBy = NULL, closedAt = NULL WHERE id = $project";
}else{
    $query = "UPDATE projectInfo SET closedBy = $idEmp, closedAt = '$today' WHERE id = $project";
}

$res = mysqli_query($link, $query);
}
    
asked by Fernando Garcia 26.11.2018 в 21:39
source

1 answer

0
function setInfoStatusProject($status, $project){
include("bd.php");
session_start();
$idEmp = $_SESSION['id'];
$today = date('Y-m-d');
if($status == 1){
    $query = "UPDATE projectInfo SET closedBy = NULL, closedAt = NULL WHERE id = ".$project;
}else{
    $query = "UPDATE projectInfo SET closedBy = ".$idEmp.", closedAt = '".$today."' WHERE id = ".$project;
}

$res = mysqli_query($link, $query);
} 

Look at how to treat the variables in the querys' string. I hope these changes work. Greetings.

    
answered by 26.11.2018 в 21:46