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
https://forums.phpfreaks.com/topic/37819-loading-wrong-info/
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
https://forums.phpfreaks.com/topic/37819-loading-wrong-info/#findComment-180998
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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