The Bonded Game Posted June 12, 2011 Share Posted June 12, 2011 Greetings, I am starting for the first time a thread. I am sure this is basic knowledge but I have, as yet, been unable to discover where it is hidden away. I would like to add a random amount of stats for my players as they do there steps in the streets mod. This would be chance 16 of quite a bit. if ($chance == 16) { $gained=rand(2,9)*$ir['level']; print "While , you come across an old tree. Using your might, you knock it down gaining <b>/$gained strength.</b>; $db->query('UPDATE `userstats` SET `strength'=strength + $gained'); "; } Ok, here is the out put from doing this step... While , you come across an old tree. Using your might, you knock it down gaining /300 strength.; ('UPDATE `userstats` SET `strength'=strength + 300'); Obviously it should not look like that. It is also not adding the strength to the player stats. Any help on this would be much appreciated. Although I would like to know what this particular piece of code is, I plan on adding this in to a lot of steps for different stats and hope that a simple generic code string would work. I appreciate your time. Quote Link to comment Share on other sites More sharing options...
bineye Posted June 12, 2011 Share Posted June 12, 2011 Problem is you have the query within the print statement. You should do the query, then print the message of "You gain blah...". Quote Link to comment Share on other sites More sharing options...
The Bonded Game Posted June 13, 2011 Author Share Posted June 13, 2011 Problem is you have the query within the print statement. You should do the query, then print the message of "You gain blah...". if ($chance == 16) { $gained=rand(2,9)*$ir['level']; $db->query('UPDATE `userstats` SET `strength'=strength + $gained'); print "While , you come across an old tree. Using your might, you knock it down gaining <b>/$gained strength.</b>; "; } adjusted it now getting this error... Parse error: syntax error, unexpected '=' in /home/thebo41/public_html/street.php on line 106 So I still have some sort of error in the code string. Quote Link to comment Share on other sites More sharing options...
Danny696 Posted June 13, 2011 Share Posted June 13, 2011 Change the query to this; $db->query("UPDATE `userstats` SET `strength'=strength + $gained"); Quote Link to comment Share on other sites More sharing options...
bineye Posted June 13, 2011 Share Posted June 13, 2011 (edited) Which line is 106? if ($chance == 16) { $gained=rand(2,9)*$ir['level']; $db->query("UPDATE userstats SET strength=strength+{$gained} WHERE userid={$ir['userid']}"); print "You come across an old tree. Using your might, you knock it down gaining <b>{$gained} strength.</b>"; } Try copying that. Should work ok. Edited June 13, 2011 by bineye Added WHERE clause 1 Quote Link to comment Share on other sites More sharing options...
The Bonded Game Posted June 13, 2011 Author Share Posted June 13, 2011 (edited) Which line is 106? if ($chance == 16) { $gained=rand(2,9)*$ir['level']; $db->query("UPDATE userstats SET strength=strength+{$gained} WHERE userid={$ir['userid']}"); *facepalm* I have been looking at these lines for so long that I forgot to mention which line 106 was. It would have been the third line in my post. Change the query to this; [php]$db->query("UPDATE `userstats` SET `strength'=strength + $gained");[/php] print "You come across an old tree. Using your might, you knock it down gaining <b>{$gained} strength.</b>"; } Try copying that. Should work ok. Sorry yours did not work though. Thank you bineye!!! Plus one for you!! Edited June 13, 2011 by The Bonded Game Noob Failure on quotes Quote Link to comment Share on other sites More sharing options...
bineye Posted June 13, 2011 Share Posted June 13, 2011 Sorry yours did not work though. Thank you bineye!!! Plus one for you!! I'm confuzzled....did it work for you or not? lol!! Quote Link to comment Share on other sites More sharing options...
The Bonded Game Posted June 13, 2011 Author Share Posted June 13, 2011 I'm confuzzled....did it work for you or not? lol!! Sorry Bineye, Yours worked perfectly!! I appreciate your help! Quote Link to comment Share on other sites More sharing options...
bineye Posted June 13, 2011 Share Posted June 13, 2011 Oh ok! No problem! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.