Jump to content

Loading Wrong Info


SoireeExtreme

Recommended Posts

Ok, I'm working on a seemingly very easy explore/walking around script for a game. But each page loads the wrong info. On each page I have the location 100, 100 (latitude) (longitude). Now say I go north it does and loads the 101 to the database as it should. But when the page loads it doesn't update the location on the page it says 100. But if I go north again It will say 101 and not 102.

 

So my question is how do I correct this in order to get the info that is loaded into the database to display correct instead of being off by one number each time?

 

If you need more info please let me know thanks.

 

This code is located at the top of the page, I've also tried it at the bottom.

if($userstats3['latitude'])
{


$north="update ac_users set latitude=latitude+'1' where playername='$player'";
mysql_query($north) or die("Could not update latitude");


}

 

This code is located in the middle of the page.

Location: $userstats3[latitude], $userstats3[longitude]

 

each of these are in their own <?php ?> along with other coding of course.

 

 

Link to comment
Share on other sites

I update the database like this... And down in the middle of the page. When I display the location from the database I use the same thing here except its in its own <??> using the player userstats from the top of the page.

 

<?php
if (isset($_SESSION['player'])) 
  {
    $player=$_SESSION['player'];
    $userstats="SELECT * from ac_users where playername='$player'";
    $userstats2=mysql_query($userstats) or die("Could not get user stats");
    $userstats3=mysql_fetch_array($userstats2);

if($userstats3['latitude'])
{

$north="update ac_users set latitude=latitude+'1' where playername='$player'";
mysql_query($north) or die("Could not update latitude");

}
    }
else
{

echo "<META HTTP-EQUIV = 'Refresh' Content = '1; URL =../index.php'>";
die("Sorry not logged in. Redirecting Now!");
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.