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

  • SEARCH
  • Home
  • 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 8985487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:20:28+00:00 2026-06-15T21:20:28+00:00

i need to subtract an mysql update. here is the code: <?php session_start(); //=============Configuring

  • 0

i need to subtract an mysql update. here is the code:

<?php
session_start();
//=============Configuring Server and Database=======
$host        =    'localhost';
$user        =    'root';
$password    =    '';
//=============Data Base Information=================
$database    =    'login';

$conn        =    mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
mysql_select_db($database,$conn) or die('Database Information is not correct');

//===============End Server Configuration============

//=============Starting Registration Script==========


$username    =    mysql_real_escape_string($_POST['txtusername']);

//=============To Encrypt Password===================

//============New Variable of Password is Now with an Encrypted Value========


$insert = "UPDATE `users` SET `points` = (`points`-5) WHERE `username` = '".$username."'";
$insert = "UPDATE `users` SET `lodd` = (`lodd` +1) WHERE `username` = '".$username."'";

 mysql_query($insert); 


header('location: succes.php');
?>

the +1 work perfect but it dont work to -5… how can i do so that they get -5 points?

  • 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-06-15T21:20:29+00:00Added an answer on June 15, 2026 at 9:20 pm

    the +1 work correctly because the query with -5 will never be called as it is overwritten by the query that has +1.

    you should have this code, (Although this is not the correct one)

    $insert = "UPDATE `users` SET `points` = (`points`-5) WHERE `username` = '".$username."'";
    mysql_query($insert);
    
    // other codes
    
    $insert = "UPDATE `users` SET `lodd` = (`lodd` +1) WHERE `username` = '".$username."'";
    mysql_query($insert); 
    

    follow-up question: what are the dataypes of the two columns? are they unsigned or signed?

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

Sidebar

Related Questions

I need to subtract 45 minutes from the date-time variable in PHP. The code:
I want to update a table with PHP and mySQL. I need to add
I'm getting caught up on PHP again, and have the following update code. This
I need to subtract two rows in MySQL by using the most recent date
I have an HTML table showing my mySQL database. I frequently need to change
I need to have a mySQL database of inventory of a particular part number.
I need to subtract time/day using a mysql query; It is something like 02:00
I need to subtract 0.5 from number a and set the answer to number
Need a map reduce function by mongo in php This my mongo structure [_id]
Need some regular expressions help. So far I have my code working to allow

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.