Jump to content
MakeWebGames

having trouble adding things to members


Hybridd

Recommended Posts

im having trying to put things in the members table on the database.

the code im using is:

mysql_query("UPDATE `members` SET `my_points` = '25',
`my_dondays` = '8', `wallet` + '50000',`gift` = 1 WHERE `playerid` = {$playerid}");
i_credit($playerid, 79, 3);

 

iv tried this.

$ddays = 8;
$udays = $pl['my_dondays'] + $ddays;
$wallet = 50000;
$uwallet = $pl['wallet'] + $wallet;
$points = 25;
$upoints = $pl['my_points'] + $points;

mysql_query("UPDATE `members` SET `my_points` = '$points',
`my_dondays` = '$ddays', `wallet` + '$wallet',`gift` = 1 WHERE `playerid` = {$playerid}");
i_credit($playerid, 79, 3);

 

basically the problem is that its not updating the tables.

Link to comment
Share on other sites

that would work kyle but the error was in this bit: {$playerid}.

i fixed it by replacing it with {$_SESSION['playerid']}

 

mysql_query("UPDATE `members` SET `my_points` ='".$upoints."',
  `my_dondays` ='".$udays."', `my_maxenergy`= '150', `my_energy`= '150', `wallet` ='".$uwallet."',`gift` = 1 WHERE `playerid` = {$_SESSION['playerid']}");
Link to comment
Share on other sites

that would work kyle but the error was in this bit: {$playerid}.

i fixed it by replacing it with {$_SESSION['playerid']}

 

mysql_query("UPDATE `members` SET `my_points` ='".$upoints."',
  `my_dondays` ='".$udays."', `my_maxenergy`= '150', `my_energy`= '150', `wallet` ='".$uwallet."',`gift` = 1 WHERE `playerid` = {$_SESSION['playerid']}");

i told you yesterday if you are going to use the $playerid variable you need to set it in the style top

Link to comment
Share on other sites

[b]Firstly declare[/b] $playerid;[b] in your styletop or header[/b]
$playerid = $_SESSION['playerid'];
[b]or if it in a switch function declare the variable[/b] $playerid = $_SESSION['playerid'];[b] outside the function and call it using "global".[/b]
$playerid = $_SESSION['playerid']; //Variable assigned to session
switch($_GET['whatever']) {
case 'index':
       index();
       break;
default: index(); break;

}
function index(){
global $playerid;
}


[b]And you where missing `wallet`as kyle stated[/b]
mysql_query("UPDATE `members` SET `my_points` = '25',
`my_dondays` = '8', `wallet` = `wallet` + '50000',`gift` = 1 WHERE `playerid` = {$playerid}");
i_credit($playerid, 79, 3);

 

- - - Updated - - -

 

[b]Firstly declare[/b] $playerid; [b]in your styletop or header[/b]
$playerid = $_SESSION['playerid']; //Variable assigned to session
[b]or if its in a switch function declare the variable[/b]$playerid = $_SESSION['playerid']; [b] outside the function and call it using "global".[/b]
$playerid = $_SESSION['playerid']; //Variable assigned to session
switch($_GET['whatever']) {
case 'index':
       index();
       break;
default: index(); break;

}
function index(){
global $playerid; //Fetches variable from outside the function
}


[b]And you where missing `wallet`as kyle stated[/b]
mysql_query("UPDATE `members` SET `my_points` = '25',
`my_dondays` = '8', `wallet` = `wallet` + '50000',`gift` = 1 WHERE `playerid` = {$playerid}");
i_credit($playerid, 79, 3);

Hope this helps.

Link to comment
Share on other sites

Firstly,

JCVenom why using $_SESSION when thats already declared with $pl in style_top

Just sloppy not using something if its already declared.

Secondly,

Hybridd

When adding to a column that already exists such as `wallet`, `my_points`, my_maxenergy & my_dondays

you want to set the column you using first IE `wallet` = `wallet`<<--(your first figure) + 100 you also dont need to put these ' around numbers.

hope this helps for the future!!

Link to comment
Share on other sites

Firstly,

JCVenom why using $_SESSION when thats already declared with $pl in style_top

Just sloppy not using something if its already declared.

Secondly,

Hybridd

When adding to a column that already exists such as `wallet`, `my_points`, my_maxenergy & my_dondays

you want to set the column you using first IE `wallet` = `wallet`<<--(your first figure) + 100 you also dont need to put these ' around numbers.

hope this helps for the future!!

Putting quotes around numbers is not entirely true. There are some instances that I have seen where the datatype is enum which is represented by a string and not an INT which you would need to put a quote around the data

Link to comment
Share on other sites

Firstly,

JCVenom why using $_SESSION when thats already declared with $pl in style_top

Just sloppy not using something if its already declared.

Secondly,

Hybridd

When adding to a column that already exists such as `wallet`, `my_points`, my_maxenergy & my_dondays

you want to set the column you using first IE `wallet` = `wallet`<<--(your first figure) + 100 you also dont need to put these ' around numbers.

hope this helps for the future!!

I actually didn't realize it was declared in the style_top, that was simply a mistake

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...