PDA

View Full Version : [php] noob > triggering msql query...



Gaelic
September 28th, 2006, 06:25 PM
I'm too used to Dreamweaver and add ons that I never really learned any normal PHP programming (well a lot but not everything heh).


<?php
$result =$_SESSION['kt_userCredits'] + $_SESSION['kt_userMoney'];
$sql = "UPDATE User SET userMoney = userMoney+userCredits, userCredits = 0 WHERE userID = 'userID'"; ?>
<? echo $result ?>.</p>

<?php if (!isset($_GET['action'] == "collect")) {
mysql_query($sql);
} ?> I have been trying to get this to work for a long time now. After playing a Flash game, the score gets sent to row userCredits.

I first tried making a form that would have a button that would cause the update, but after 3 days of struggling with that, I ran out of ideas...

I guess something's wrong with the GET function... if someone could help me out, that'd be greatly appreciated :hugegrin:

bwh2
September 28th, 2006, 06:53 PM
<?php
$kt_userCredits = $_POST['kt_userCredits'];
$kt_userID = $_POST['kt_userID'];

$sql = "UPDATE User SET userMoney = userMoney+'$kt_userCredits', userCredits = 0 WHERE userID = '$kt_userID'";

if (!isset($_POST['action'] == 'collect')) {
$results = mysql_query($sql);
}i think that's what you're trying to do. you should also be using POST instead of GET to prevent users from just injecting scores into the GET.
?>

Gaelic
September 28th, 2006, 06:59 PM
Ooh thank you, I'll try that right now!

Gaelic
September 28th, 2006, 07:07 PM
Hm... no, that didn't work... :(

bwh2
September 28th, 2006, 07:21 PM
are you sending the variables with those names and via POST? are you sending action as well via POST?