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

**URL:** https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172
**Category:** programming
**Created:** [July 11, 2004, 1:44am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172 "2004-07-11T01:44:44Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 4:49am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/21 "2004-07-11T04:49:29Z")

</div>

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;

```php

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

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 4:54am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/22 "2004-07-11T04:54:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 4:55am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/23 "2004-07-11T04:55:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 4:56am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/24 "2004-07-11T04:56:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 4:59am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/25 "2004-07-11T04:59:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:03am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/26 "2004-07-11T05:03:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:08am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/27 "2004-07-11T05:08:46Z")

</div>

```php

 $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](http://php.net) are good resources 🙂  
\*\*

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:12am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/28 "2004-07-11T05:12:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:18am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/29 "2004-07-11T05:18:38Z")

</div>

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](http://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).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:43am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/30 "2004-07-11T05:43:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:46am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/31 "2004-07-11T05:46:19Z")

</div>

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](http://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 ?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:52am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/32 "2004-07-11T05:52:21Z")

</div>

i did that and it worked i donno whats up

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 5:57am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/33 "2004-07-11T05:57:00Z")

</div>

$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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 6:02am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/34 "2004-07-11T06:02:13Z")

</div>

what is the output of …

```php

   echo $HTTP_SESSION_VARS['user_name'];
   

```

Before running the query…  
and this how i like to do my queries.

```php

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

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 6:10am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/35 "2004-07-11T06:10:38Z")

</div>

it didnt work lol

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 6:13am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/36 "2004-07-11T06:13:54Z")

</div>

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

```php

 print_r($_SESSION); #whats the output.. copy and paste it please
 

```

whats ure php build ?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 6:17am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/37 "2004-07-11T06:17:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 6:24am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/38 "2004-07-11T06:24:00Z")

</div>

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

```php

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 6:27am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/39 "2004-07-11T06:27:40Z")

</div>

And

```php

#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']."'";

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2004, 10:44am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/40 "2004-07-11T10:44:41Z")

</div>

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

[Previous page](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172.md?page=1)
