General Community > Scripting Help
Database Query Problem
The Wizard:
@Suki
So your saying the code should look like this -
--- Quote ---function onUse() {
global $smcFunc;
$result = $smcFunc['db_query']('', '
UPDATE {$db_prefix}members
SET shop_Flag = {string:flag}
array(
'id_member' => $message['member']['id'],
'limit' => 1,
'flag' => $_POST['flag']
)
}
--- End quote ---
Suki:
No, you removed the WHERE part, so now the query will be executed on every row, not a good thing.
--- Code: ---unction onUse() {
global $smcFunc;
$result = $smcFunc['db_query']('', '
UPDATE {$db_prefix}members
SET shop_Flag = {string:flag}
WHERE id_member = {int:id_member}
array(
'id_member' => $message['member']['id'],
'flag' => $_POST['flag']
)
}
--- End code ---
This will only modify the flag column in the member's specific row. Take the old 1.1.x query as an example, the only thing you need to change is how you will perform the query but the query itself is still the same.
K@:
I removed your double-topic, Wiz.
Pretty pointless, doing that.
The Wizard:
Thanks K
The Wizard:
Ok so here is the final product - I hope fingers crossed :)
--- Quote ---function onUse() {
global $smcFunc;
$result = $smcFunc['db_query']('', '
UPDATE {$db_prefix}members
SET shop_Flag = {string:flag}
WHERE id_member = {int:id_member}
array(
'id_member' => $message['member']['id'],
'limit' => 1,
'flag' => $_POST['flag'],
)
);
}
--- End quote ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version