# 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:** 1

<div class="post-metadata">

**Author:** ![Berone](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Berone](https://forum.kirupa.com/u/Berone)\
**Post date:** [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/1 "2004-07-11T01:44:44Z")

</div>

\<?  
session\_start();  
$conn = mysql\_connect(“XXX”, “XXX”, “XXX”);  
mysql\_select\_db(“XXX”,$conn);

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

---

<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, 2:15am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/2 "2004-07-11T02:15:26Z")

</div>

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

---

<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, 3:03am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/3 "2004-07-11T03:03:41Z")

</div>

This doesn’t belong in Flash ActionScript so I moved it over.

When $\_POST[‘score’] isn’t set, is the script still supposed to run?

If you’re just trying to add score to the gold, you can always go

“UPDATE mytable SET cash = cash + score WHERE… etc”

hope this helps

---

<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, 3:39am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/4 "2004-07-11T03:39:33Z")

</div>

$q = “update usergame set cash = cash + $score where user\_name = ‘$HTTP\_SESSION\_VARS[user\_name]’”;  
mysql\_query($q);

i used that and it still doesn’t add cash to score to get cash…  
it just inserts score

if have if (!$\_POST[‘score’]) {  
do this  
} else {  
$score = $\_POST[‘score’];

etc…

i donno why cash doesn’t register… score should be the one that doesn’t

---

<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, 3:41am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/5 "2004-07-11T03:41:40Z")

</div>

i put if (!$gold) {

before to see if gold even got selected and it didnt

---

<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, 3:54am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/6 "2004-07-11T03:54:28Z")

</div>

```php

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

```

---

<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, 3:57am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/7 "2004-07-11T03:57:01Z")

</div>

Its updating fine the process is that cash isn’t getting selected and gold isn’t getting defined

---

<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:08am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/8 "2004-07-11T04:08:34Z")

</div>

```php

 #try this.
  $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'] + $score;
 echo $gold; #to check if its all oke.
 $q = "update usergame set cash ='".$gold."' where user_name ='".$HTTP_SESSION_VARS[user_name]."'";
 $result = mysql_query($q) or die(mysql_error()); 
 echo $result; #debug whats output..
 }
 

```

---

<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:15am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/9 "2004-07-11T04:15:08Z")

</div>

ok  
i found the error Resource id #2  
when itry and select cash  
i donno what the means or how to fix it

---

<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:21am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/10 "2004-07-11T04:21:26Z")

</div>

$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

---

<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:22am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/11 "2004-07-11T04:22:56Z")

</div>

oh i gues that status = 1 should just be 1 so yea it updated fine

---

<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:24am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/12 "2004-07-11T04:24:43Z")

</div>

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.

---

<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:26am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/13 "2004-07-11T04:26:30Z")

</div>

lol yea it does help but my problem still remains! i can’t get cash selected

---

<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:28am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/14 "2004-07-11T04:28:08Z")

</div>

Resource id #2 thats the error message i get when i try and select stufff

---

<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:29am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/15 "2004-07-11T04:29:24Z")

</div>

Well as i said execute that query in a prompt window or [www.mysqlfront.de](http://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!

---

<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:30am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/16 "2004-07-11T04:30:25Z")

</div>

Resource id #2 do u kno what that means though?

---

<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:32am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/17 "2004-07-11T04:32:47Z")

</div>

```php

#this into 
$sql_res = mysql_query($sql,$conn) or die(mysql_error());
#this
$sql_res = mysql_query($sql) 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, 4:33am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/18 "2004-07-11T04:33:41Z")

</div>

It means something wrong with the query 🙂 Thats why you should try them out in a query window instead from php pages. it really helps!

---

<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:36am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/19 "2004-07-11T04:36:17Z")

</div>

Resource id #2  
i still get it 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, 4:47am UTC](https://forum.kirupa.com/t/someone-help-me-i-have-problem-with-sending-data-to-my-mysql-table/57172/20 "2004-07-11T04:47:51Z")

</div>

the thing updates fine it just doesn’t select cash

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