Jump to content

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

Link to comment
https://forums.phpfreaks.com/topic/2865-error-using-now/
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--]

Link to comment
https://forums.phpfreaks.com/topic/2865-error-using-now/#findComment-9655
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

Link to comment
https://forums.phpfreaks.com/topic/2865-error-using-now/#findComment-9661
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.