Equip problem?

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Andrew
Posts: 16
Joined: Mon Aug 15, 2011 12:57 pm

Equip problem?

Post by Andrew »

I've got a problem: When I press Equip in the Equipment menu it says:

(!) Notice: Undefined index: location in C:\wamp\www\???????\equipped.php on line 35



Code:

Code: Select all

 <?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
   <html>
    <head>
     <div>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="style.css" rel="stylesheet" type="text/css" />
   </head>
     </div>
     </html>
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$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';
$id=$playerinfo3['id'];
?>
</div>
<div id="table">
 <?php
	    $type=$_GET['type'];
           $location=$_GET['location'];
	   $randid=$_GET['randid'];
	  
	   if ($type=="w")
	   {
	 $updateequip="Update playerweapons SET equip=0 WHERE pid='$id' AND equip=1";
	    mysql_query($updateequip) or die("Could not update equipment");	
		 $reequip="Update playerweapons set equip=1 where pid='$id' AND randid='$randid'";
	    mysql_query($reequip) or die("Could not update equipment2");	
		
		echo "<center><big><big>Weapon Equipped<br></big></big>";
		echo "<br><A href='index.php'>Go back</a>";
		}
		if ($type=="a")
	  {
	   $updateequip="Update playerarmor SET equip=0 WHERE pid='$id' AND equip=1 AND location='$location'";
       mysql_query($updateequip) or die("Could not update armor");   
      
      
       $reequip="Update playerarmor set equip=1 where pid='$id' AND randid='$randid' AND equip=1 AND location='$location'";
       mysql_query($reequip) or die("Could not update armor2"); 	
		
		echo "<center><big><big>Armor Equipped<br></big></big>";
		echo "<br><A href='index.php'>Go back</a>";
		}
  
  ?>

</div>

Thank you :)

Andrew
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: Equip problem?

Post by Ark »

Well make sure that when you make your 'equip' url in your equipment menu, to add ?randid=$randid something like that.

So your 'equip' url should be: equipped.php?randid=2132135&location=blabla&type=arktype /// (bad order btw)

idk something like that xD ..

cuz your equipped.php is like hey wtf, where's the $_GET['randid'], $_GET['location'], $_GET['type'] ?!?!

hope that solves the problem.
Orgullo Catracho
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Equip problem?

Post by Callan S. »

Code: Select all

$location=$_GET['location'];
If location hasn't been passed through the address line, then this is what is causing your error

You need to test if location has been passed through the address line with

Code: Select all

if (isset($_GET['location']))
{
$location=$_GET['location'];
}
else // it hasn't been passed through the address line
{
echo "No location given<br>";
exit;
}
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Post Reply

Return to “Advanced Help and Support”