Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- ?>
- <?php
- // Adjust MySQL connection settings...
- $mysql_hostname = "localhost";
- $mysql_user = "root";
- $mysql_password = "";
- $mysql_database = "gametest";
- $bd = mysql_connect($mysql_hostname, $mysql_user,$mysql_password) or die("<h2>Opps
- something went wrong</h2>");
- mysql_select_db($mysql_database, $bd) or die("<h2>Opps something went wrong</h2>");
- // $sql="SELECT * FROM users where id='{$_SESSION['refcode']}'";
- $sql="select com_balance, refcode, id from users where
- refcode='{$_SESSION['username']}' limit 1";
- $val = 2;
- $result = mysql_query($sql,$bd);
- $data=mysql_fetch_assoc($result);
- while ($array = mysql_fetch_array($result)) {
- // equate the value to a variable to use outside
- // this while loop
- $ref = $array{$_SESSION['username']};
- $acc_balance = $array['com_balance'];
- }
- $remainder = $acc_balance + $val;
- $update_query = mysql_query("UPDATE users SET com_balance = '".
- mysql_real_escape_string($remainder) ."'
- WHERE refcode='{$_SESSION['username']}'");
- if ($update_query) {
- print "Update successful, {$data['com_balance']}, {$data['refcode']}";
- }
- // Otherwise...
- else {
- print "Sorry, the username {$_SESSION['username']} was not found in our database...";
- }
- ?>
Add Comment
Please, Sign In to add comment