Jump to content

Archived

This topic is now archived and is closed to further replies.

sgiandhu

Error using NOW()

Recommended Posts

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

Share this post


Link to post
Share on other sites

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--]

Share this post


Link to post
Share on other sites

[!--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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.