Someone help me... I have problem with sending data to my mysql table

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 ?
 

kk i did that and stil no go
it still got gold as 0

this works when i go to it but it doesn’t work when i use it with my flash game

when i don’t use it with the flash game i get that same Resource #id=2 error but the gold outputs correctly

so if echo $gold; =0 ? it messes things up there right ? did you do a google ?

yea gold should actually = something over 0 cuz its set at like 100 right now i think

lol no i haven’ done a google but i did google looking for that resource #id thinger couldn’t find anything lol u try u sound like a pro googler


 $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 ???

google as php.net are good resources :slight_smile:
**

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

so you mean $stats[‘cash’] has not the right value ?
but it is updating correcly with the right values ???

Am i missing something here?

How is it getting defined, and how should it be ??? and what is the code belonging to that part ( not the whole thing/script. … )

and what was the output of the small echo ing script above, what is it doing and what should it be ?

ps:
php.net

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 ?

i did that and it worked i donno whats up

$asdf = “select cash from usergame where user_name = ‘$HTTP_SESSION_VARS[user_name]’” or die(mysql_error());
$asdf_res = mysql_query($asdf) or die(mysql_error());
srand ((float) microtime() * 10000000);
while ($cats = mysql_fetch_array($asdf_res)) {

its doing everything in here so i know its found the data

i changed it to that… i still get that resource erro and it doesn’t work

what is the output of …


   echo $HTTP_SESSION_VARS['user_name'];
   

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());
   

it didnt work lol

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 ure php build ?

oh no the session var printed… everything works fine i donno what the big prob is

#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.!

And


#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.