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 7647541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:29:18+00:00 2026-05-31T10:29:18+00:00

<? require (tracker.php); ?> <center> <?php include ‘dbc.php’; ?> <title>J~Net Level Up</title> <?php session_start();

  • 0
<? require ("tracker.php");

?>


<center>
<?php 
include 'dbc.php';


?>
<title>J~Net Level Up</title>
 <?php session_start();
 $id = $_SESSION['user_id']; 
 // Connects to your Database 
 mysql_connect("localhost", "root", "") or die(mysql_error()); 
 mysql_select_db("messages") or die(mysql_error()); 
 $data = mysql_query("UPDATE `users` SET `balance` = `balance` - 1000 WHERE `users`.`id` =$id") 
 or die(mysql_error()); 
 echo "<table border cellpadding=3>"; 
 while($info = mysql_fetch_array( $data )) 
{ 
 echo "<tr>"; 
 echo "<th>User:</th> <td>".$info['user_name'] . "</td> "; 
 echo "<th>Balance:</th> <td>".$info['balance'] . " </td></tr>"; 
 } 
 echo "</table>";
 // echo "Balance Is ".$_SESSION['balance']; 
echo $row['user_name'] . " " . $row['balance'];
 ?>
<META HTTP-EQUIV=REFRESH CONTENT="0; URL=010101levup.php">

as you can see in above code it doesnt check if balance is available before it executes and balance goes into minus, is there a simple way it can have a if statement to make sure balance is available first before it executes the sql statement?

please help with this minor glitch what i need is a pro to edit the above code not tell me what lines needs to be added as before when this happens its untested and when i test it it fails so i need it to make sure balance is in there and if yes it goes to that refresh line (at bottom of code block),

and if there is insufficient funds it should return an error and not goto last line of code.

Please help if you can i can supply any sql you may need for this to test your end if required!

  • 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-31T10:29:20+00:00Added an answer on May 31, 2026 at 10:29 am

    Add some extra logic to the where clause:

    $update = 1000;
    
    UPDATE users
    SET balance = balance - $update
    WHERE (users.id = $id) AND
       (balance >= $update)
    

    The update will still run, but only actually change the record if the balance is high enough to begin with.

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

Sidebar

Related Questions

require_once'modules/logger.php'; $Logger = new Logger(); require_once 'templates/list.php'; $Templates = new templatesList(); require_once 'widgets/list.php'; $Widgets
I require a tree / directed acyclic graph implementation something like this: public class
I require a star rating control (which allows partial rating like 4.5) for my
I require a SQL script to validate a VARCHAR field in a table in
I require a means of checking to see if a string has the following
I require help to search a text file (log file) using c# and display
I require the syntax of a CMAKE macro that generates .cc and .h files
C# doesn't require you to specify a generic type parameter if the compiler can
Like many companies that require all access be through stored procedures, we seem to
This will require a little setup. Trust me that this is for a good

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.