if ($_POST[‘score’]) {
$score = $_POST[‘score’];
}
print “status=Finished”;
$sql = “select * from XXX where user_name = ‘XXX’”;
$sql_res = mysql_query($sql,$conn) or die(mysql_error());
srand ((float) microtime() * 10000000);
while ($stats = mysql_fetch_array($sql_res)) {
$gold = $stats[‘cash’];
}
$gold = $gold + $score;
$q = “update usergame set cash = ‘$gold’ where user_name = ‘$HTTP_SESSION_VARS[user_name]’”;
mysql_query($q);
?>
$gold outputs as 0
$score which is the score from the flash game works!
cash is updated to the same as score… because $gold doesn’t register!
help i donno why this does htis
I think the problem is that when i try and select data … it doesnt work because i tried to select something else and it didn’t work…
ugh… this is driving me nuts
$result = mysql_query($q) or die(mysql_error());
#this is for debuggin of queries which should really
#add to all queries when still
#underconstruction
echo $result;
$gold = 406 $result = status=1
$gold shouldn’t of been 406 becuase 406 is what i scored…
it should of added 100 to 406
because 100 was my initial gold but i tdidnt select it right
As you can see now, echoing back youre variables for debug is a very good thing to do it will solve alot of youre problems while coding the pages. the mysql_error is the same thing. And if the query really doesnt work try it directly from the prompt command or in any other query window. that to will make you see youre errors very fast.
Well as i said execute that query in a prompt window or www.mysqlfront.de use that t00l thats what i use, it helps me with a lot of things… or just phpmyadmin… make the query in the query window and see if you get results. and again echo back all vars that you needs to see where it went wrong!