-1

This is my code for updating. it displays "Done" but if you check the database, the fields are not updating.

What's wrong with my code?

<?php include('include/dbconnect.php');

$page = $_POST['newpage'];
$title = $_POST['newtitle'];
$content = $_POST['newcontent'];
$track_no = $_POST['track_no'];
$done = "UPDATE contents SET page = '$page',title = '$title', content = '$content', modified = 'CURDATE()'WHERE track_no = '$track_no' ";     
$result = mysql_query($done) or die(mysql_error());
if (!$result)
{
    print "Something is wrong!";
}
else{
    print "Done!";
}

?>
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78

2 Answers2

0

just remove quote from your sql

$done = "UPDATE contents SET page = '$page',title = '$title', content = '$content', modified = CURDATE() WHERE track_no = '$track_no' ";
Lokesh Jain
  • 579
  • 6
  • 19
-1

your doing right one, but silly mistake only, YOU SHOULD MUST REMOVE THE SINGLE QUOTE IN CURDATE like as,

$done = "UPDATE contents SET 
page = '$page',
title = '$title', 
content = '$content', 
modified = CURDATE() 
WHERE 
track_no = '$track_no' ";     

Note: Any kind of date or time don't mention in quote. Not this one 0000-00-00 00-00-00

RGK
  • 40
  • 9
  • This wouldn't result in a query not working, it would only result in the field being `0000-00-00`. Also, date or time values HAVE to have quotes. Function calls can't have quotes. – Gerald Schneider Sep 20 '14 at 07:32
  • [http://stackoverflow.com/a/25946267/3640589] @GeraldSchneider how did you score 5000 and above, hey you should must learn the mysql your query doesn't work, **because your missing the single quote** you should must changed the query and after u'll advise others.... – RGK Sep 20 '14 at 09:44
  • @GeraldSchneider do you want a upvote means tell me i'll give you, don't doing like this... – RGK Sep 20 '14 at 09:52