Jump to content

cloudll

Members
  • Posts

    131
  • Joined

  • Last visited

Everything posted by cloudll

  1. I have been echo'ing the random number and it is correctly outputting a number from 1-6. But the battle is still activating on any number it feels like. But with no pattern what so ever. Sometimes it's a 1, sometimes a 5 etc. The reload function just updates the script to reflect the changes but I actually removed it to test this error and just forgot to take it out of this post.
  2. Hey guys, I'm having some trouble with mt_rand on a game I'm working on, at least I think thats the problem. If the activeBattle condition is 'no', and the number 1 is generated by mt_rand, the code is supposed to start a battle by updating my database. The only issue is, it seems to be starting the battle on any number. Its completly random which number activates the battle. There is no pattern. Here is the code, does anyone have any ideas why this may be happening? $encounter = mt_rand(1, 6); if (($encounter == 1) && ($activeBattle == 'no')) { $active = "yes"; $id = 1; $sql = "UPDATE encounter SET active=? WHERE id=?"; $statement = $connect->prepare($sql); $statement->execute(array($active,$id)); reloadPage(); }
  3. your awesome thanks
  4. I am trying to use a variable in heredoc to absolutley position a css div. position: absolute; top:$pos_ypx; left:$pos_xpx; The problem is, as it looks at the moment, it thinks the variable name is $pos_xpx and not just $pos_x. If i leave a space ($pos_x px) the css does not work. Is there anyway to make php ignore the px part when calling the variable?
  5. Thats great, thank you.
  6. Hey everyone, I have just transfered to a new server and an getting a few error messages now. I am getting this one: PHP Notice: Undefined index: movement in on line 113. Which is this line of code: $movement = $_REQUEST['movement']; This worked fine on my old server but I'm guessing maybe this one has stricter error reporting maybe. Is it due to the fact that unless I make the url request, $movement is empty ? Sorry still a novice at PHP.
  7. Hey guys, I am currently using the following code to connect to my database and to display custom messages for if it has connected to the database or not. I would quite like to display these messages in my footer. I was wondering if its possible to turn the messages into a variable to echo them in the footer? Thanks for any tips. $hostname = 'localhost'; $database = 'engine'; $username = 'root'; $password = ''; try { $dbh = new PDO("mysql:host=$hostname;dbname=$database", $username, $password); echo 'Connected to database'; } catch(PDOException $e) { echo 'error connecting to database.'; } error_reporting(0);
×
×
  • 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.