Reputation: 373
When code updates date field in database, the date becomes 0000/00/00. But when I print the date variable in web page with echo
, output prints correct date. Any ideas how could update work.
Code:
$query=date('y/m/d');
$date="UPDATE student SET datum_upisa=$query WHERE _broj_indeksa='$broj_indeksa'";
mysqli_query($con,$date);
Upvotes: 3
Views: 576
Reputation: 28751
$date="UPDATE student SET datum_upisa='$query'
WHERE _broj_indeksa='$broj_indeksa'";
When you use $query instead of '$query' , MySql is not able to parse a literal string $query to date type and silently converts to a zero value.
Upvotes: 1
Reputation: 10563
You have to use '$query'
instead of $query
$date="UPDATE student SET datum_upisa='$query' WHERE _broj_indeksa='$broj_indeksa'";
Upvotes: 4
Reputation: 3453
use quote for date
, change this line
$date="UPDATE student SET datum_upisa='$query' WHERE _broj_indeksa='$broj_indeksa'";
Upvotes: 4