• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[SQL] get value and use in other query

okurde

New Member
Joined
Jan 28, 2009
Messages
134
Reaction score
1
Hello, I want to get referrer (it's account_id) from accounts and use it in next query

I have:

Code:
$accountID = $_REQUEST['custom']; // user account ID

$ref2 = "SELECT `referrer` FROM `accounts` WHERE `accounts`.`id`= '".mysql_real_escape_string($accountID)."';";
mysql_query($ref2);

$sqltest = "UPDATE `accounts` SET `premium_points` = `premium_points`+ 10 WHERE `accounts`.`id` = '".mysql_real_escape_string($ref2)."' ";
mysql_query($sqltest);


And it does not work. How can I get value and use in another query?

Btw I must use this syntax, "$variable = $SQL->query ( ... ) -> fetch();" will not work here
 
I don't see your point, can't you just use the ID like the first statement?
Code:
"UPDATE `accounts` SET `premium_points` = `premium_points`+ 10 WHERE `accounts`.`id` = '".mysql_real_escape_string($accountId)."' "
 
Back
Top