sgiandhu Posted November 15, 2005 Share Posted November 15, 2005 Hi there, I am updating some information in a DB with a short form. However, inserting the date into the update field is being a bit of a trial. partial code posted: the problem is evidently in this section if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "formname")) { $updateSQL = sprintf("UPDATE tblName SET access=%s, uname=%s, password=%s, NOW() WHERE memberID=%s", GetSQLValueString($_POST['access'], "int"), GetSQLValueString($_POST['uname'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['info_update'], ''), GetSQLValueString($_POST['memberID'], "int")); mysql_select_db($database_name, $dbname); $Result1 = mysql_query($updateSQL, $dbname) or die(mysql_error()); I get an error message saying MySQL doesn't like my use of NOW() where it is in relation to the WHERE command... Anyone able to correct me here? Many thanks J Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 15, 2005 Share Posted November 15, 2005 you're not telling SQL what to update as NOW()... you have to assign it to a column just like all your other updates: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] tableName SET `[span style=\'color:blue;font-weight:bold\']update[/span]_time` = NOW() WHERE... [!--sql2--][/div][!--sql3--] Quote Link to comment Share on other sites More sharing options...
sgiandhu Posted November 15, 2005 Author Share Posted November 15, 2005 [!--quoteo(post=318842:date=Nov 15 2005, 09:38 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Nov 15 2005, 09:38 AM) 318842[/snapback][/div][div class=\'quotemain\'][!--quotec--] you're not telling SQL what to update as NOW()... you have to assign it to a column just like all your other updates: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] tableName SET `[span style=\'color:blue;font-weight:bold\']update[/span]_time` = NOW() WHERE... [!--sql2--][/div][!--sql3--] Thank you .. how obvious! I did actually figure this out by looking at another post, however, having my thought process confirmed is very nice. I appreciate the help. That's twice in 2 days I've had help here, so I'm off to make my donation. Cheers and many thanks again J Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.