01-22-2008, 08:25 PM
|
#2 (permalink)
|
|
The Addict
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
|
One problem, karq, and that is your number (not the guess) doesn't persist. This means that if the number is 1 the first time and I say 3, the returned message is that the number is smaller. So, next time I pick 2 ... only to have it tell me the number is bigger.
Try using a cookie to make the random number persist.
PHP Code:
<?php
// This MUST be at the top before ANY output happens! if(!isset($_COOKIE['arva'])) { // The zero makes it expire when the browser session terminates. setcookie('arva', rand(1,20), 0); } $arva = intval($_COOKIE['arva']); ?>
Now, put that at the top and remove the parts within your section that assign values to arva. Now it'll persist between guesses and you can get it right. 
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
|
|
|
|