Look. echo back all the vars you need, where ever a variable is not being returned thats where you need to look. And try them from a query window !
also try them directly without using a $var example;
# dont put in $username, but something like administrator if thats the user_name
$sql = "select * from users where user_name=administrator";
#and
echo stats['cash']; #does this return a echo ?
$gold = '11';
$cash = '2';
$gold = $gold + $cash;
echo $gold;
#this will give a output of 13 so nothing wrong with youre code there.
#that means you need to check something here if $gold = 0
echo 'Score =';
echo $_POST['score'];
echo '<br>Cash = ';
echo $stats['cash'];
$gold = $_POST['score'] + $stats['cash'];
echo 'Total gold = ';
echo $gold;
So one of them should be empty which is it ? and what is youre query compleet, personally i do not care about youre table name neither about the variable you use for username however it might help.
** And did you try the query in a query window instead using the php page ???
i tried that where i est $gold as a certain thing and it worked it added gold to score right … the prob is that the column cash isn’t getting defined as gold and its drinvg me nuts
If you use mysql_connect with identical parameters twice (e.g. a second connection to log all sql queries without an impact on the first one), the resource variables will be different (echo $dbl says Resource id #1, echo $dbl_log says Resource id #2), but in some way the same (mysql_insert_id($dbl) and mysql_insert_id($dbl_log) are always identical).
the $stats[‘cash’]; has a value of 0 when it should have a value of like somethjing above 0… and i get the resource 2 erorr but i donno what that means exacstly
did you try the query window ??? AS i already stated out a couple of time…
again resource ids. basicly mean ( no mather which number it has, that you screwed up in the query. )
download this tool. www.mysqlfront.de (mysql front ) install it… than connect to youre database and run this query -> select cash from users where user_name=‘administrator’ <-(example) query does that comes up with any result ?
Before running the query…
and this how i like to do my queries.
#this only for query window !
#select cash from usergame where user_name
#did you actually do that www.mysql-front.de again.
$asdf="SELECT * FROM usergame WHERE user_name='".$HTTP_SESSION_VARS['user_name']."'";
$asdf_res = mysql_query($asdf) or die(mysql_error());
well there you go, like i said a long long long long time ago… echo youre $vars that you need.
since echo $HTTP_SESSION_VARS[‘user_name’]; didnt work or came up emtpy the problem is somewhere else, like as in where did you said the SESSION VAR ?
do this for a minute
print_r($_SESSION); #whats the output.. copy and paste it please
#whats the output… copy and paste it please
And if that as you said is not null, than you did not complete youre query in a q window as i asked you, because that measn that the query should get executed without RCid and than the $stats[‘cash’] shouldnt be NULL.
#other way to fetch array
while($result = mysql_fetch_assoc($query)) {
echo $stats['cash'];
You are messing up somwhere, however if you are not able to post the things that are asked, (giving back the outputs for example… ))helping you is impossible.!
#if that indeed give result meaning user_name was there in the print_r($_SESSION);
#do this...
$asdf="SELECT * FROM usergame WHERE user_name='".$_SESSION['user_name']."'";
It seems wierd that you use where user_name = ‘XXX’ when you do the select and where user_name = ‘$HTTP_SESSION_VARS[user_name]’ when you update. They should be the same.
It’s also a bit wierd that you loop around fetching the rows you’ve selected. Shouldn’t there only be one? If there are more, the amount of gold is set to the last row you fetch and you ignore the rest.
Also in your select you have from XXX. That should be from usergame.