Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Databasing
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 05-14-2008, 03:12 PM
  #1
Novus Mortuus
Myrmidon (Level 12)
 
Join Date: Feb 2008
Posts: 158
iTrader: (0)
Novus Mortuus is an unknown quantity at this point
Addition

I just cannot work this out.

I'm trying to update a table in my database every time someone posts on the forum, and add 1 to the field user_forum_posts

I can't/don't want to use a auto increment, because that wouldn't work, as there is more than 1 user and it would..well it wouldn't work, i'm sure you can see why.

I've been through loads of MySQL references, and the cloesest i can find is a Mathematical Function of + but i can't work out how to use it

I've tried:

PHP Code:
UPDATE  `***`.`user_infoSET  `user_forum_posts` +1 WHERE  `user_info`.`user_id` =2 LIMIT 1 
PHP Code:
UPDATE  `***`.`user_infoSET  `user_forum_posts` + '1' WHERE  `user_info`.`user_id` =2 LIMIT 1 
PHP Code:
UPDATE  `***`.`user_infoSET  `user_forum_posts` = +1 WHERE  `user_info`.`user_id` =2 LIMIT 1 
PHP Code:
UPDATE  `***`.`user_infoSET  `user_forum_posts` = SUM(+1WHERE  `user_info`.`user_id` =2 LIMIT 1 
etc....

Novus Mortuus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-15-2008, 07:43 AM
  #2
putts
Don't call it a comeback.
 
putts's Avatar
 
Join Date: Nov 2002
Location: Frankenmuth, MI
Posts: 4,721
iTrader: (0)
putts will become famous soon enoughputts will become famous soon enough
it should be something like this....

UPDATE user_info SET user_forum_posts = user_forum_posts + 1 WHERE `user_info`.`user_id` =2 LIMIT 1 ;
__________________


Dont like my signature image? Click it to change it
putts is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-15-2008, 09:11 AM
  #3
Novus Mortuus
Myrmidon (Level 12)
 
Join Date: Feb 2008
Posts: 158
iTrader: (0)
Novus Mortuus is an unknown quantity at this point
In the end i just did this:

$forumposts = $user['forum_posts'];
$forumposts = $forumposts + 1;

UPDATE user_info SET forum_posts = '$forumposts' ....

Thanks though.
Novus Mortuus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-15-2008, 11:30 AM
  #4
Vege
♥♥♥
 
Vege's Avatar
 
Join Date: Sep 2004
Location: Finland
Posts: 2,500
iTrader: (0)
Vege will become famous soon enough
Even thou mysql allows adding "character" into int field i still would use

Quote:
UPDATE user_info SET forum_posts = ".intval($forumposts);
notice that strings are encapsulated with '', integers are not.
__________________
I read the bible
Specially pg.681
Vege is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply
« Previous Thread | Next Thread »


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 04:10 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.