Jump to content
MakeWebGames

SwiftLeeO

Members
  • Posts

    3
  • Joined

  • Last visited

SwiftLeeO's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Okay, so I need opinions. I'm thinking of building a webgame on the CodeIgniter framework. - Is this a good idea? - Is there anything I should know before hand?
  2. Well, this is pretty simple to do, but hopefully it will help beginners who want to incorporate a chance into their script, but do not know how to go about it.   <?php /* This function creates a probability system. If the number is below the percentage provided, then it will trigger the code within the IF statement. If the number is above the percentage provided, then it will trigger the code within the ELSE statement. $num is an integer between 0 and 100. $perc is an integer that defines the probability of win vs. loss Currently if the number is less than or equal to the percentage, it will return true. If it is not, it will return false. This allows you to use it for many different situations. A demonstration is provided below the function. */ function chance($perc){ $perc += 0; $num = mt_rand(0, 100); if($num <= $perc){ return true; } else { return false; } } /* If returned true, print Successful! If returned false, print Failure! You can pretty much do anything with this as far as percentage goes. You could insert a value into the database on a win/loss, give the user a prize... It really doesn't matter; It's completely up to you. */ if(chance(100)){ echo 'Successful!'; } else { echo 'Failure!'; } ?>
  3. Okay, well from what I understand, MySQL is deprecated, so the two other options are either MySQLi, or PDO. I chose to look into PDO (PHP Data Objects). I have a question for anyone who has some grasp on it. 1. Do prepared statements eliminate SQL injections?
×
×
  • Create New...