Page 1 of 1

Query Help

Posted: Sun Mar 07, 2004 12:04 pm
by HaVoC

Code: Select all

<?php
$id = $_GET['id']; 
$winner = $_GET['winner']; 
$loser = $_GET['loser']; 
$observer = $_GET['observer']; 

MySQL_query("UPDATE ldu_users SET wins = wins - 1, points = points - 2 WHERE user_name = {$winner}");
MySQL_query("UPDATE ldu_users SET losses = losses - 1, points = points + 1 WHERE user_name = {$loser}");
MySQL_query("UPDATE ldu_users SET obs = obs - 1 WHERE user_name = {$observer}");
?>
Ok I used the get ID in another query. And it always works. What is wrong with the queries you see? It has to do with the queries.

Posted: Sun Mar 07, 2004 12:13 pm
by JAM
Imagine my name is Foo Bar, and what that does to a query:

Code: Select all

MySQL_query("UPDATE ldu_users SET wins = wins - 1, points = points - 2 WHERE user_name = Foo Bar");
Can you see what the issue will be?

Try adding singe quotes around values:

Code: Select all

MySQL_query("UPDATE ldu_users SET wins = wins - 1, points = points - 2 WHERE user_name = '&#123;$winner&#125;'");

Posted: Sun Mar 07, 2004 12:24 pm
by HaVoC
Well I thought of doing that, but in phpMyAdmin the query told me to use " " and when I did it worked. But when I did it outside of phpMyAdmin I got a parse error :(

Posted: Sun Mar 07, 2004 12:37 pm
by JAM
Adding " " (double quotes) within the lines you posted first, would break them for sure with parsing errors.

There is a difference between single ' and double " quotes, and I'm just trying to make sure you use it correctly. No matter how good we all think phpMyAdmin is, there are issues with it's query-tool if used incorrectly.

" In phpMyAdmin, might aswell be ' in php outside phpMyadmin.

Posted: Sun Mar 07, 2004 5:28 pm
by HaVoC
Thanks ^^