Page 1 of 1

Equip problem?

Posted: Sun Aug 21, 2011 1:43 pm
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

Re: Equip problem?

Posted: Mon Aug 22, 2011 5:29 am
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.

Re: Equip problem?

Posted: Mon Aug 22, 2011 7:53 am
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;
}