Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,182 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,115 people online right now. Registration is fast and FREE... Join Now!




updatung my data base

 
Reply to this topicStart new topic

updatung my data base

ghqwerty
29 Aug, 2008 - 09:31 AM
Post #1

D.I.C Regular
Group Icon

Joined: 8 Aug, 2008
Posts: 373



Thanked: 8 times
Dream Kudos: 25
My Contributions
ok so i cant for the life of me see why this isnt working please could someone help me


php

<?php
$winning = (check($bet));
?>

<?php

require("conn.php");

$playerid = 1;

//did player win or lose?
if($winning > 0){
$playersnew = $winning;// will add money to player
$banksnew = ($winning)*-1; // will take the money off bank value the *-1 makes it negative
}else{
$banksnew = $winning; // will add money to bank
$playersnew = ($winning)*-1;// will take the money off player value the *-1 makes it negative
}

$sql = 'SELECT * FROM slots WHERE playerId = '.$playerid.' LIMIT 1';
$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_array($result);

$updatedbankmoney = ( $row['banksmoney'] + $banksnew); // if $banksnew is negative this will take

money off, even though it's + $banksnew
$updatedplayermoney = ($row['playersmoney'] + $playersnew);// if $playerssnew is negative this

will take money off, even though it's + $playersnew

$result = mysql_query("UPDATE slots SET banksmoney='.$updatedbankmoney.', playersmoney =

'.$updatedplayermoney.' WHERE playerid='.$playerid.'")
or die(mysql_error());

?>



<div align="center">
you bet : <?php echo $bet; ?>
<br>
and you won : <?php check($bet); ?>


<?php
function check($bet)
{
global $one;
global $two;
global $three;
global $peach;
global $apple;
global $cherries;
global $coin;

if($one == $peach && $two == $peach && $three == $peach) {
echo $bet*3;
}elseif(($one == $peach && $two == $peach) || ($one == $peach && $three == $peach) || ($two ==

$peach && $three == $peach)){
echo $bet*2;
}elseif($one == $apple && $two == $apple && $three == $apple){
echo $bet*10;
}elseif($one == $cherries && $two == $cherries && $three == $cherries){
echo $bet*20;
}elseif($one == $coin && $two == $coin && $three == $coin){
echo $bet*50;
}elseif(($one == $coin && $two == $coin) || ($one == $coin && $three == $coin) || ($two == $coin

&& $three == $coin)){
echo $bet*5;
}else{
echo 0;
}
}
?>


This post has been edited by ghqwerty: 29 Aug, 2008 - 10:16 AM
User is offlineProfile CardPM
+Quote Post

akozlik
RE: Updatung My Data Base
29 Aug, 2008 - 09:37 AM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Feb, 2008
Posts: 714



Thanked: 31 times
Dream Kudos: 800
My Contributions
The query looks fine.

Are you getting an error? If so, post it.

Also, can you post your database schema?

Echo out the values of your variables before the query triggers and make sure they're what you expect them to be. i.e., if you're expecting a playerid and none is present, that would be your problem.

This post has been edited by akozlik: 29 Aug, 2008 - 09:39 AM
User is offlineProfile CardPM
+Quote Post

JBrace1990
RE: Updatung My Data Base
29 Aug, 2008 - 09:53 AM
Post #3

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 479



Thanked: 24 times
Dream Kudos: 350
My Contributions
php
$result = mysql_query("UPDATE slots SET banksmoney='.$updatedbankmoney.', playersmoney = '.$updatedplayermoney.' WHERE playerid='.$playerid.'")   


That query is off... you're putting into the database value .NUMBER., which would end up as 0, or something around there plus or minus the bet...

if the DB is set to varchar, you should be able to see it, but if it's set to int, it'll come up to 0...
User is offlineProfile CardPM
+Quote Post

ghqwerty
RE: Updatung My Data Base
29 Aug, 2008 - 10:04 AM
Post #4

D.I.C Regular
Group Icon

Joined: 8 Aug, 2008
Posts: 373



Thanked: 8 times
Dream Kudos: 25
My Contributions
QUOTE(akozlik @ 29 Aug, 2008 - 10:37 AM) *

The query looks fine.

Are you getting an error? If so, post it.

Also, can you post your database schema?

Echo out the values of your variables before the query triggers and make sure they're what you expect them to be. i.e., if you're expecting a playerid and none is present, that would be your problem.


no errors just my banksmoney and players money are staying at 1000

my database has 3 fields
playerid
banksmoney
playersmoney


have changed them to varchar

after echoing my variables i found my $banksnew just stays at 0 when i lose it doesnt go up and when i win it doesnt go down .. but shouldnt my players money column still change ???

User is offlineProfile CardPM
+Quote Post

Mcbazzo
RE: Updatung My Data Base
29 Aug, 2008 - 10:10 AM
Post #5

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

wat r u using coz everyone seems to have a simlar screen (for codes) but cnt get it up

User is offlineProfile CardPM
+Quote Post

ghqwerty
RE: Updatung My Data Base
29 Aug, 2008 - 10:14 AM
Post #6

D.I.C Regular
Group Icon

Joined: 8 Aug, 2008
Posts: 373



Thanked: 8 times
Dream Kudos: 25
My Contributions
you mean this
php
$blahblahblah=blah;
???


just put [ code = php ] code [ \ code ]

but without the spaces

User is offlineProfile CardPM
+Quote Post

Mcbazzo
RE: Updatung My Data Base
29 Aug, 2008 - 10:23 AM
Post #7

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

i see but im using wamp, do you know how to put in codes?
User is offlineProfile CardPM
+Quote Post

ghqwerty
RE: Updatung My Data Base
29 Aug, 2008 - 10:25 AM
Post #8

D.I.C Regular
Group Icon

Joined: 8 Aug, 2008
Posts: 373



Thanked: 8 times
Dream Kudos: 25
My Contributions
add me on msn

rugbyismysoulx@hotmail.co.uk

please keep to the topic
User is offlineProfile CardPM
+Quote Post

Mcbazzo
RE: Updatung My Data Base
29 Aug, 2008 - 10:38 AM
Post #9

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

QUOTE(ghqwerty @ 29 Aug, 2008 - 11:25 AM) *

please keep to the topic

Ok Sorry

QUOTE(ghqwerty @ 29 Aug, 2008 - 11:25 AM) *
add me on msn

rugbyismysoulx@hotmail.co.uk

Have Done

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:51AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month