Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Nah, that seems too manual and too crude to me. Debbie Too manual? Well generally configuration options are... This is the best way to make sure your URL's are correct. Things may vary in server configurations and such, and if you need to dynamically create URL's for example then you have a way to control them.
  2. I added it, but I made a typo - so here it is: if ($userGuess<$randNum) { echo "<center>You guessed too low!</center>"; $_SESSION['guesses']++; } if ($userGuess>$randNum) { echo "<center>You guessed too high!</center>"; $_SESSION['guesses']++; } if ($userGuess==$randNum) { echo "<center>Congratulations You're right!!!</center>"; unset($_SESSION["randNum"], $_SESSION['guesses']); } Note the "$_SESSION['guesses']++" lines. Every time they make a wrong guess, the guesses is increment.
  3. Try this: game.php <?php session_start(); $_SESSION['randNum'] = isset($_SESSION['randNum']) ? $_SESSION['randNum'] : rand(1, 100); $_SESSION['guesses'] = isset($_SESSION['guesses']) ? $_SESSION['guesses'] : 0; ?> <html> <body> <center><form action="game_check.php" method="POST"> Guess a number 1-100:<input type="text" name="userGuess"/> <input type="submit" value="Guess"/> </form></center> <center><form action="game.php"> <input type="submit" value="Restart"/> </form></center> </body> </html> game_check.php <?php session_start(); $randNum = $_SESSION['randNum']; $userGuess=$_POST["userGuess"]; if (isset($randNum)) { if ($userGuess<$randNum) { echo "<center>You guessed too low!</center>"; $_SESSION['randNum']++; } if ($userGuess>$randNum) { echo "<center>You guessed too high!</center>"; $_SESSION['randNum']++; } if ($userGuess==$randNum) { echo "<center>Congratulations You're right!!!</center>"; unset($_SESSION["randNum"], $_SESSION['guesses']); } } else { echo "Uh oh"; } ?>
  4. Firstly, you should use isset() instead of == null. In your code, if a field is left out you will get a PHP Notice: undefined index. Secondly I believe this is your problem: if ([array count] == 0) It should be if (empty($error)) {
  5. That is pretty unlikely to happen if you use one of the more popular ones (IE: CodeIgniter, Kohana, Symfony, CakePHP, Zend, etc).
  6. You could use is_int() to see if it is a number. And you could use strlen() to see if it is a certain amount of characters. $price = $_POST['price']; if (is_int($price) && strlen($price) == 5) { // good to go } What do you mean by "run a script"? strip_tags() will remove HTML tags, which could prevent XSS attacks.
  7. I really doubt you will have that kind of control over any shared hosting. You'll likely need a VPS for that.
  8. I don't see a question anywhere. What is this doing or not doing that isn't right?
  9. I guess I am confused. Why don't you just change what is included already to instead use the newer version of jQuery?
  10. I could help more if you showed me the markup in which you are using this, but maybe this will get you started: http://jsfiddle.net/kgeHe/1/
  11. I think you want something like this: http://jsfiddle.net/kgeHe/
  12. I believe the GROUP BY function is what you are looking for. SELECT * FROM SELECT * FROM uitems WHERE username='$showusername' AND location='2' GROUP BY name Also, you shouldn't use mysql_fetch_array() unless you for some reason specifically require what it does. mysql_fetch_array() returns both an associative array and a numerical array, so your array holds the contents twice - and this is entirely unnecessary. You should either use mysql_fetch_row() (if you want a numerical array) or mysql_fetch_assoc() (if you want an associative array - which in your example, you do).
  13. Like I said, without showing me the markup for your dropdown then I really can't help you any further. Maybe this example will help you: http://jsfiddle.net/uKpUC/
  14. I don't know because I'm not familiar with it. However you can easily solve this by giving each form field a unique name. So like iks1, iks2, iks3 ... etc.
  15. Open your web browser, and go to http://localhost Any PHP files will need to be in the server document root. This is defined in Apache's virtual host config file. So if you put "insert_ac.php" in the document root (which appears to be C:\wamp\www in your case) then you would then type http://localhost/insert_ac.php into your web browser.
  16. Hmm. Without knowing how you wish to use the information I can't offer a better suggestion. But if it's available today, it should also be available in the future no?
  17. I use Eclipse PDT. I just like the feel of it. Powerful if it needs to be, but simple and elegant if not. I also use Notepad++ for quick edits and such.
  18. That's because (I'm assuming) quickform automatically loads the values back into the form when you press submit. And since they all have the same names, they all get the same value.
  19. I don't know - how do you have codeigniter set up?
  20. Oh, I see. Is the reserved_to/from fields DATE/DATETIME? If yes you can try WHERE reservations.reserved_to < CURDATE()
  21. Because they all have the same name.
  22. I believe he updated your jsfiddle.
  23. In PHP, variables cannot start with a number. Where is this $1 supposed to be coming from? EDIT: Maybe this is what you wanted? $postip = $argv[1];
  24. So are you getting any Javascript errors?
  25. You then need to use it via $this->ci->session instead of $this->session EDIT: Wait, so you autoloaded the session? In that case, while in another library you need to take the same steps but you don't need to load it. So in another library: $CI =& get_instance(); $CI->session->userdata();
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.