Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 811533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:03:37+00:00 2026-05-15T01:03:37+00:00

Hi I have a MySQL database table points the user can click a button

  • 0

Hi I have a MySQL database table “points” the user can click a button and a point should be removed from their account, the button they pressed has an ID of another user, therefore their account must increase by one.

I have it working in jQuery and checked the varibles/posts in Firebug, and it does send the correct data, such as:

userid= 1 
posterid = 4

I think the problem is with my PHP page:

<?php


include ('../functions.php');

$userid=mysql_real_escape_string($_POST['user_id']);
$posterid=mysql_real_escape_string($_POST['poster_id']);

if (loggedin()) 
{
include ('../connection.php');
$query1 = "UPDATE `points` SET `points` = `points` - 1 WHERE `userID` = '$userid'";
$result1=mysql_query($query1);


$query2 = "UPDATE `points` SET `points` = `points` + 1 WHERE `userID` = '$posterid'";
$result2=mysql_query($query2);


if ($result1 && result2)
{
    echo "Successful";  
    return 1;
}
else
{

    echo mysql_error();
    return 0;   
}
}
?>

Any ideas? Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:03:37+00:00Added an answer on May 15, 2026 at 1:03 am

    Two queries to increase/decrease field value are not necessary:

    UPDATE table SET field = field + 1 WHERE id = 1
    

    is a perfectly valid query as you can see next:

    mysql> describe points;
    +--------+---------+------+-----+---------+-------+
    | Field  | Type    | Null | Key | Default | Extra |
    +--------+---------+------+-----+---------+-------+
    | uid    | int(11) | NO   | PRI | NULL    |       |
    | points | int(11) | YES  |     | 0       |       |
    +--------+---------+------+-----+---------+-------+
    2 rows in set (0.05 sec)
    
    mysql> insert into points VALUES (1,0),(2,0);
    Query OK, 2 rows affected (0.14 sec)
    
    mysql> select * from points;
    +-----+--------+
    | uid | points |
    +-----+--------+
    |   1 |      0 |
    |   2 |      0 |
    +-----+--------+
    2 rows in set (0.05 sec)
    
    mysql> update points set points = points+1 where uid = 1;
    Query OK, 1 row affected (0.27 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select * from points;
    +-----+--------+
    | uid | points |
    +-----+--------+
    |   1 |      1 |
    |   2 |      0 |
    +-----+--------+
    2 rows in set (0.00 sec)
    

    Having that tested, are you sure you get into your if (loggedin()) clause?

    I have to agree with KM, would be nice to see output of echo $query1; or echo $query2;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I actually had to look into a similar issue a… May 16, 2026 at 11:50 am
  • Editorial Team
    Editorial Team added an answer OK, turned out I needed to set: self.wantsFullScreenLayout = YES;… May 16, 2026 at 11:50 am
  • Editorial Team
    Editorial Team added an answer It looks like you can match and replace ^[\d-]*\s* with… May 16, 2026 at 11:50 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a form that is sending data to a MySQL database and I
Let's say I have a mysql table, called foo with a foreign key option_id
I use a form where i have listed the data from database like title,
I have a mysql Database and 2 tables let's say clients and schools. Now
Suposse I have the next MySQL database with 500.000 rows : users { id
I have a timestamp in a database table. Now everytime a record is amended
I have a java program that connects to a MySql database and it's working
I have 2 tables: user_tb.username user_tb.point review_tb.username review_tb.review I am coding with PHP(CodeIgniter). So
I have a php / mysql / jquery web app that makes 13 ajax
I have some CSV data files that I want to import into mySQL. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.