The code work fine in the phpmyadmin but when i try to do it with php from the website it doesn't change the value :/ help !?
enter code here
<?php
include_once 'logiranje.php';
$maticen = $conn->real_escape_string($_POST['maticenpromena']);
$naziv = $conn->real_escape_string($_POST['nazivsmetka']);
if ($naziv=="Participacija")
{
$naziv = "101010";
}
else if ($naziv=="Materijali") //problem here it was IF instead of ELSE IF
{
$naziv = "202020";
}
else
$naziv = "303030";
$mesec = $conn->real_escape_string($_POST['mesec']);
$godina = $conn->real_escape_string($_POST['godina']);
$sql = "UPDATE imaat SET imaat.platena=true WHERE imaat.embg=$maticen AND
imaat.id_smetka= $naziv AND imaat.mesec=$mesec AND
imaat.godina=$godina;";
mysqli_query($conn,$sql);
header("Location: ../smetki.php?platenasmetka=success");
?>
your sql is not correct, try with this:
$sql = "UPDATE imaat SET imaat.platena=true WHERE imaat.embg=".$maticen." AND
imaat.id_smetka=". $naziv." AND imaat.mesec=".$mesec." AND
imaat.godina=".$godina;
or
$sql = "UPDATE imaat SET imaat.platena=true WHERE imaat.embg='$maticen' AND
imaat.id_smetka='$naziv' AND imaat.mesec='$mesec' AND
imaat.godina='$godina'";
when you insert $var inside your query , you are not put the value of variable , but the word $var that why , he can't find a row thoses variables names.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.