Jump to content

replies=replies+1 wont work


Baseball

Recommended Posts

mysql_query("UPDATE forum_topics   SET `time`='".time()."', ".
                                            "lastposter='{$_SESSION['user_name']}', ". 
										"lastposterid='{$_SESSION['user_id']}', ". 
										"lastposttime='"         .time()          ."', ". 
										"replies='replies+1'".
										"WHERE id='"        .$tid               ."'") or die(mysql_error());

 

why wont my replies work .. ?

 

im add replies=replies+1 and im not getting error either

Link to comment
https://forums.phpfreaks.com/topic/186255-repliesreplies1-wont-work/
Share on other sites

i believe it should be something like:

 

mysql_query("UPDATE forum_topics   SET `time`='".time()."', ".
                                            "lastposter='{$_SESSION['user_name']}', ".
                                 "lastposterid='{$_SESSION['user_id']}', ".
                                 "lastposttime='"         .time()          ."', ".
                                 "replies=(forum_topics.replies+1)".
                                 "WHERE id='"        .$tid               ."'") or die(mysql_error());

 

but not sure (may need to SELECT that field and update using php first.

 

-CB-

ChemicalBliss is right.. although the table isnt required.. Your original query would work if you remove the code from quotes..

mysql_query("UPDATE forum_topics   SET `time`='".time()."', ".
                                            "lastposter='{$_SESSION['user_name']}', ".
                                 "lastposterid='{$_SESSION['user_id']}', ".
                                 "lastposttime='"         .time()          ."', ".
                                 "replies=replies+1".
                                 "WHERE id='"        .$tid               ."'") or die(mysql_error());

Archived

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

×
×
  • 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.