Page 1 of 1

me again

Posted: Fri Aug 14, 2009 2:37 am
by Torniquet
:p

ok. everything looks right. but isnt working right :s

Code: Select all

                        $looseexp = rand(1,$cexp);
			$lostexp = $pexp - $looseexp;
			
			if($lostexp < 0){
				$lostexp = $pexp;
			}
			
			$result = "You managed to get away successfully. But you lost " . $looseexp . " experience.";
			
			mysql_query("UPDATE stardrome_playerinfo SET occupy_id='0', experience='$lostexp' WHERE id='$id'");
if the $lostexp is lower than 0 (i.e minus figures) it is MENT to equal the $pexp (players current exp)

but it doesnt :s

it equals 0 for some reason. can anyone see where i might have ballsed up? i have tried making it 'if($lostexp > $pexp){.....

but that doesnt do the trick either. i have tried wrapping 0 in quotes, still no joy.

it works fine if $lostexp is lower than $pexp... but not other way round :(

any one see anything i have misseD?

Re: me again

Posted: Fri Aug 14, 2009 3:13 am
by SpiritWebb
I'm just taking a shot in the dark. But to me, I see a . next to experience and "

... you lost " . $looseexp . " experience."; /// should that . be there?

Re: me again

Posted: Fri Aug 14, 2009 3:29 am
by Torniquet
lol yes. because it indicates a full stop :p the others are concatinating.

there is no problem with that part of the code. i dont know why i included it tbh lol.

its the if section thts not working right :(

Re: me again

Posted: Fri Aug 14, 2009 3:34 am
by SpiritWebb
And you have $pexp defined?

Re: me again

Posted: Fri Aug 14, 2009 7:44 am
by jpoisson
mysql_query("UPDATE stardrome_playerinfo SET occupy_id='0', experience='$lostexp' WHERE id='$id'")or die('_'.mysql_error());

give us the error message it brings fourth...

Re: me again

Posted: Fri Aug 14, 2009 12:32 pm
by Torniquet
hmmm i swear i am so mentally retarded :s

I worked out the problem :D

i was making $lostexp equal $pexp ..... which is why it wasnt altering when the if statment was ran ¬¬ so I have made it equal 0 as it is ment to lol. christ knows what i was thinkin when i made it do that lol. and how i didnt spot it before i will never know :D


n e whos thanks for the replies guys :p x

Re: me again

Posted: Fri Aug 14, 2009 3:59 pm
by Jackolantern
Almost all of my problems so far with PHP scrips have ended up being silly, unlike Java or C# problems, which is usually a mistake with the convoluted class libraries lol.

Re: me again

Posted: Fri Aug 14, 2009 5:07 pm
by Torniquet
Jackolantern wrote: unlike Java or C# problems, which is usually a mistake with the convoluted class libraries lol.
if it ok with you. i am going to pretend to know what the hell you are going on about :p


but yeah. just makes u wanna go... DUH!!!