Map Location Issue

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Map Location Issue

Post by Epiales »

I noticed in your video where you put locations from your index instead of using another page. I decided to do another page, based upon my setup. When I switch it to an internet server, that may change, but in the meantime I want to use map.php, which I have the code below.

Code: Select all

<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
 $id=$_SESSION['id'];
    echo "You must be logged in to view this page!";
}else{
?>


<?php
if(!isset($_GET['map'])){

$id = $user['id'];
$bypass=1;
echo "<a href='map.php?mapchange=1&mapname=Las Vegas'>Las Vegas</a><br /><br />";
echo "<a href='map.php?mapchange=1&mapname=Reno Nevada'>Reno Nevada</a><br /><br />";
echo "<a href='map.php?mapchange=1&mapname=St Louis Missouri'>St Louis Missouri</a><br /><br />";
}

if(!isset($_GET['mapchange'])){

$bypass=1;
$mapname = $_GET['mapname'];

$updateplayer="update stats set location='$mapname' WHERE id='$id'";
  mysql_query($updateplayer) or die("Could not update player");
  
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='map.php'>To location</a><br>";

    }
    }
?>
Now I didn't see any difference in my code and yours, so I'm lost on why I get the error.... This is what it shows:

Las Vegas

Reno Nevada

St Louis Missouri


Notice: Undefined index: mapname in C:\xampp\htdocs\game\map.php on line 25
You have traveled to .
To location
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Map Location Issue

Post by Epiales »

Okay, I have to remove the:

{
$bypass=1;

From the top and it now shows the first two locations but not the current one. And it shows that you have traveled there and updates in db....

current code:

Code: Select all

<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){

    echo "You must be logged in to view this page!";
}else{
$id = $user['id'];
if(isset($_GET['map']))


echo "<a href='map.php?mapchange=1&mapname=Crocania'>Crocania</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Fordale Woods'>Fordale Woods</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Mintus Mountains'>Mintus Mountains</a><br>";
}

if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];

$updateplayer="update stats set location='$mapname' where id='$id'";
  mysql_query($updateplayer) or die("Could not update player");
  
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='map.php'>To location</a><br>";
}

?>
not sure why it doesn't show the current location, and not sure why I had to remove the bypass?
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Map Location Issue

Post by Epiales »

Okay.. LOL..Not sure why it's not working, but doing it this way works:

Code: Select all

echo "<a href='map.php?mapchange=1&mapname=Las Vegas'>Las Vegas</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Reno Nevada'>Reno Nevada</a><br>";
echo "<a href='map.php?mapchange=1&mapname=St Louis Missouri'>St Louis Missouri</a><br>";
echo "<a href='map.php?mapchange=1&mapname=Las Vegas'>Las Vegas</a><br>"; 
and I have to leave that first Las Vegas in there or the Reno doesn't show LOL. Oh well, it works YAY
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
MikuzA
Posts: 394
Joined: Thu Aug 08, 2013 8:57 am

Re: Map Location Issue

Post by MikuzA »

Hello,

You might want to simplify the links, instead of mapname use id.
Unable to analyse the issue more closely at this time, nyt sure looks a bit weird.
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Post Reply

Return to “Beginner Help and Support”