What's wrong with..

Location of the Videos
Post Reply
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

What's wrong with..

Post by Huezzer »

Hey I'm just wondering what's wrong with this code:
I want it to get you to a different location. Deep lake if you are Level 20 and Dark Cave if you are 40. And if you aren't the requiered level it will say: "You are not high level enough for this location", And it will send you back to the previous location. Also when you travel to a location it will
cost ''X'' gold. And if you haven't got the money, "You don't have enough gold for this trip" Or something like that. but can't figure out how to do it, just getting errors etc., Hope you know what I mean. (by the way: It says errror: Line 52, 53, 54 (marked) and it warns for error with $location.

Thanks!

Code: Select all

<?php
include_once 'connect.php';
session_start();

include 'logo.php';
?>
 <link href="style.css" rel="stylesheet" type="text/css" />
<div id="location">


<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='loginpage.php'>Click here for Loginpage!</a>";
  exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
 ?>
 <div id ="locations">
 <?php
$playerhp = $playerinfo3['stamina'];
if ($playerhp < 1)
{
  echo "You are dead!" ;
  echo "<br><a href='useitem.php>Use an Item";
  exit;
}

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

echo "<a href='index.php?mapchange=1&mapname=Forbidden Forest'>Forbidden Forest<br>";
echo "<br><a href='index.php?mapchange=1&mapname=Deep Lake'>Deep Lake<br>";
echo "<br><a href='index.php?mapchange=1&mapname=The Dark Cave'>The Dark Cave<br>";
}

if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];
$name = $locations['name'];  <-----------Line 52,53 etc.
$level = $locations['level'];
$price = $locations['price'];
$gold = $price['gold'];

$updateplayer="update players set location='$mapname' where name='$playerinfo3[name]'";
  mysql_query($updateplayer) or die("Could not update player");

$updateplayer="update players set gold='$gold' where name='$player'";
{
 echo "You do not have enough gold for this trip!";
   echo "<center><a href='index.php'>Go Back</center>";
  exit;

if ($playerinfo3['level'] > $location['level'])
{
echo "You are not high level enough to get to this Area!";
echo "<center><a href='index.php'>Go Back</center>";
exit;

  if (playerinfo3['gold'] = location['price'])
{
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='index.php'>To location</a><br>";
exit;
}

if($bypass = 1)
{
echo "<br><b><big><u>" . $playerinfo3['location'] . "</u></big><br>";
echo "<br><b><big><u>Locations</u></big></b>";
echo "<br><a href='store.php'>Visit Store<br>";
echo "<a href='inn.php'>Visit Innkeeper<br>";
echo "<a href='spelltrainer.php'>Visit Spell trainer<br>";
echo "<a href='useitem.php'>Use Items<br>";
echo "<a href='armorshop.php'>Visit Armorshop!<br>";
echo "<a href='weaponshop.php'>Visit Weaponshop<br>";
echo "<a href='battle.php'>Battle in Arena<br>";
echo "<a href='game.php?map=1'>Go to Map</a><br>";
}
}
?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>
Last edited by Huezzer on Mon Mar 14, 2011 7:41 pm, edited 1 time in total.
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Re: What's worng with..

Post by Huezzer »

Anyone?
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: What's worng with..

Post by Chris »

Hi, im in the coffee shop rather stoned and on my phone so it's difficult to copie and paste yor code, but because you asked, I think on what I'm guessing is line 56, your sql query says "set location : '$mapname' or something, but I'm guessing the variable shoulx be $name
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: What's worng with..

Post by hallsofvallhalla »

you dont have a query for $locations['name']...
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Re: What's wrong with..

Post by Huezzer »

Thank you halls!, I'll make a new code for it and I'll post it here. And you will see if I made it :P

Huezzer. :)
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Re: What's wrong with..

Post by Huezzer »

Hey, I think this is totaly wrong because I get an error:

**Parse error: syntax error, unexpected '[' in C:\wamp\www\tutorial\index.php on line 56

Index.php

Code: Select all

<?php
include_once 'connect.php';
session_start();
include 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>ZonThiz</title>
<div id="login">
<div id="login2">


<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
echo "<center><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Not Logged in <br><br> <A href='login.php'>Login</a></center>";
  exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
 ?>
<div id ="locations">
<?php
$bypass= 0;
$playersm = $playerinfo3['stamina'];
if ($playersm < 1)
{
  echo "You are dead!" ;
  echo "<br><a href='useitem.php>Use an Item";
  exit;
}

if (isset($_GET['map']))
{
$bypass=1;
echo "<a href='index.php?mapchange=1&mapname=Forbidden Forest'>Forbidden Forest";
echo "<br><a href='index.php?mapchange=1&mapname=Savannah'>The Savannah";
echo "<br><a href='index.php?mapchange=1&mapname=Deep Lake'>Deep Lake";
echo "<br><a href='index.php?mapchange=1&mapname=The Dark Cave'>The Dark Cave";
}

if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];
$name = $location['name'];
$location = $location['level'];
$level = playerinfo3['level'];
$price = $location['price'];
$gold = $price['gold'];

$query = "SELECT location,name from locations where name='$locations' AND name='$name'";
  $location = mysql_query($query) or die("Could not query locations");
  $location2 = mysql_fetch_array($location);
  
$updateplayer="update players set location='$mapname' where name='$playerinfo3[name]'";
  mysql_query($updateplayer) or die("Could not update player");

$updateplayer="update players set gold='$gold' where name='$player'";
{
echo "You do not have enough gold for this trip!";
   echo "<center><a href='index.php'>Go Back</center>";
  exit;

if ($playerinfo3['level'] > $location['level'])
{
echo "You are not high level enough to get to this Area!";
echo "<center><a href='index.php'>Go Back</center>";
exit;
}
if (playerinfo3['gold'] = location['price'])
{
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='index.php'>To location</a><br>";
exit;
}

if($bypass = 1)
{
echo "<br><b><big><u>" . $playerinfo3['location'] . "</u></big><br>";
echo "<br><b><big><u>Locations</u></big></b>";
echo "<br><a href='store.php'>Visit Store<br>";
echo "<a href='inn.php'>Visit Innkeeper<br>";
echo "<a href='spelltrainer.php'>Visit Spell trainer<br>";
echo "<a href='useitem.php'>Use Items<br>";
echo "<a href='armorshop.php'>Visit Armorshop!<br>";
echo "<a href='weaponshop.php'>Visit Weaponshop<br>";
echo "<a href='battle.php'>Battle in Arena<br>";
echo "<a href='game.php?map=1'>Go to Map</a><br>";
}
}
?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>
And I think This part is wrong, Am I right?:

Code: Select all

$mapname = $_GET['mapname'];
$name = $location['name'];
$location = $location['level'];
$level = playerinfo3['level'];
$price = $location['price'];
$gold = $price['gold'];

$query = "SELECT location,name from locations where name='$locations' AND name='$name'";
  $location = mysql_query($query) or die("Could not query locations");
  $location2 = mysql_fetch_array($location);
User avatar
62896dude
Posts: 516
Joined: Thu Jan 20, 2011 2:39 am

Re: What's wrong with..

Post by 62896dude »

Sorry, I couldn't quite figure out what is wrong :/ but i was skimming through your code, and funny enough, I am making a harry potter game right now also! :)
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
User avatar
PaxBritannia
Posts: 680
Joined: Sun Apr 18, 2010 1:54 pm

Re: What's wrong with..

Post by PaxBritannia »

$level = playerinfo3['level'];
playerinfo3 needs '$' before it. So it becomes:
$level = $playerinfo3['level'];
You've also left it out at line 79 as well. Just use Ctrl+F and search for "playerinfo" until you find the ones missing it. :)

pax.
User avatar
62896dude
Posts: 516
Joined: Thu Jan 20, 2011 2:39 am

Re: What's wrong with..

Post by 62896dude »

Nice catch Pax! :)
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: What's wrong with..

Post by hallsofvallhalla »

so whats all wrong now?
Post Reply

Return to “Older Browser MMO Videos”