me again

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

me again

Post 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?
New Site Coming Soon! Stay tuned :D
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: me again

Post 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?
Image

Image
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: me again

Post 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 :(
New Site Coming Soon! Stay tuned :D
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: me again

Post by SpiritWebb »

And you have $pexp defined?
Image

Image
jpoisson
Posts: 245
Joined: Sun Aug 02, 2009 5:12 pm

Re: me again

Post 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...
Laguages:
PHP, MYSQL, (X)HTML, HTML5, JQuery, CSS 3.0,
C, C#, C++, Python, Pascal, Perl, Ruby, Turing

Software:
Adobe MC CS4, Visual Studio 2008, Notepad++,
NetBeans IDE, WAMPSERVER

Browsers:
Internet Explorer, Firefox, Opera, Safari, Chrome
(Always have latest patches for browsers.)

Free time:
...
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: me again

Post 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
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: me again

Post 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.
The indelible lord of tl;dr
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: me again

Post 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!!!
New Site Coming Soon! Stay tuned :D
Post Reply

Return to “Coding”