• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Need help with a SQL string

nystrom

New Member
Joined
Nov 17, 2009
Messages
269
Reaction score
0
Working on a script and i realased i cant a shit about Sql.

I need to check if two string is right. Frist this.
PHP:
mysql_query("UPDATE accounts SET premium_points = +='$addpoints' WHERE accounts.id = '{$account_id}'");

ans second this:

PHP:
	mysql_query("UPDATE zaypay_payment (payment_id, account_id, status) VALUES ('{$Zaypay->getPaymentId()}', '{$_SESSION['account']}', 'PAID')");


First need to do this. Insert to accounts -> player_point, Add "addpoints" to value.

Second need to change: Zaypay_payment ->status, Change to "PAID"
Anyone?
 
Last edited:
Working on a script and i realased i cant a shit about Sql.

I need to check if two string is right. Frist this.
PHP:
mysql_query("UPDATE accounts SET premium_points = +='$addpoints' WHERE accounts.id = '{$account_id}'");

ans second this:

PHP:
	mysql_query("UPDATE zaypay_payment (payment_id, account_id, status) VALUES ('{$Zaypay->getPaymentId()}', '{$_SESSION['account']}', 'PAID')");


First need to do this. Insert to accounts -> player_point, Add "addpoints" to value.

Second need to change: Zaypay_payment ->status, Change to "PAID"
Anyone?

The first one, if you want to insert some value, you have to use "INSERT" instead of "UPDATE". The second one is that you use "UPDATE". And you kinda switched the parameters. I think you want to add more points to the player in the first one, so I guess you can use "UPDATE", but I'm not sure how to increment in SQL. One thing that I would do is to retrieve the player's point, add more points through PHP or whatever language you are using, and then update the line with the new points.

About the parameters:

PHP:
Insert: "INSERT INTO table_name VALUES (value1, value2, value3,...)"
Update: "UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value"

got it? ^_^
 
The first one, if you want to insert some value, you have to use "INSERT" instead of "UPDATE". The second one is that you use "UPDATE". And you kinda switched the parameters. I think you want to add more points to the player in the first one, so I guess you can use "UPDATE", but I'm not sure how to increment in SQL. One thing that I would do is to retrieve the player's point, add more points through PHP or whatever language you are using, and then update the line with the new points.

About the parameters:

PHP:
Insert: "INSERT INTO table_name VALUES (value1, value2, value3,...)"
Update: "UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value"

got it? ^_^


May be ^^ What do you think about this, Does it look better?

INSERT INTO Acoounts VALUES (premium_points =+$addpoints)"
Update: "UPDATE zaypay_payment SET column1=status, WHERE some_column=PAID"
 
May be ^^ What do you think about this, Does it look better?

INSERT INTO Acoounts VALUES (premium_points =+$addpoints)"
Update: "UPDATE zaypay_payment SET column1=status, WHERE some_column=PAID"

Let me explain better. The first one, you want to add more points to the player, right? So, you could get how much points this player has now, add more points and then update the players. Maybe like this:

PHP:
$result = mysql_query("SELECT premium_points FROM players WHERE id = $playerid",$connection);
$ammount = mysql_result($result,0,premium_points);
$ammount = $ammount + $addpoints;
mysql_query("UPDATE players SET premium_points = $ammount WHERE id = $playerid");

Where:
premium_points : name of the field in table players that stores player's points
players : name of table in database that stores the players
id : name of the field in table players that means the unique ID of the player
$playerid : variable of PHP where you store player's id
$connection : variable that stores the result of mysql_connect()
$addpoints : variable that stores how many points you want to add


About the second one, where I put colum_name or table_name, you should replace with the name of the colum and table, respectively.

I'm not sure if I explained right, but if you have doubts, just ask :D
 
Code:
mysql_query ( " UPDATE `players` SET `premium_points` = `premium_points` + 666 WHERE `name` = 'account name'; " );
 
Let me explain better. The first one, you want to add more points to the player, right? So, you could get how much points this player has now, add more points and then update the players. Maybe like this:

PHP:
$result = mysql_query("SELECT premium_points FROM players WHERE id = $playerid",$connection);
$ammount = mysql_result($result,0,premium_points);
$ammount = $ammount + $addpoints;
mysql_query("UPDATE players SET premium_points = $ammount WHERE id = $playerid");

Where:
premium_points : name of the field in table players that stores player's points
players : name of table in database that stores the players
id : name of the field in table players that means the unique ID of the player
$playerid : variable of PHP where you store player's id
$connection : variable that stores the result of mysql_connect()
$addpoints : variable that stores how many points you want to add


About the second one, where I put colum_name or table_name, you should replace with the name of the colum and table, respectively.

I'm not sure if I explained right, but if you have doubts, just ask :D

Argh! I now understand your one!
First it select the player points then it add amount.
And amout = + addpoints from config.


But isnt it better to do like this with the player id thing.
Select the Account wich is loggen on, Then add points to the acc?
 
Argh! I now understand your one!
First it select the player points then it add amount.
And amout = + addpoints from config.


But isnt it better to do like this with the player id thing.
Select the Account wich is loggen on, Then add points to the acc?

I'm not sure if adding points while player is logged on works, but if you want to do it, try it. I just didn't understand what you want to do with player's id.
 
Back
Top