Page 2 of 7

Re: Video #18

Posted: Tue Dec 22, 2009 10:18 pm
by sonicatu
OldRod wrote:
sonicatu wrote:can u upload the sql database too?:)
I'm not home to check this for sure, but I think there is an *.sql file in the download link above. That has the db structure in it.
u`r right.. didn't see it :)

Re: Video #18

Posted: Fri Jan 01, 2010 5:08 am
by ZeroComp
hey halls. noticed I couldn't see my experience without going in the database
so I fixe it to say Experience=x
echo "Experience = " . $playerinfo3['exper'] . "<br>";
thats how you do it put it in after attack and defense and you may have to shift lpanel down a bit but it works :D

Re: Video #18

Posted: Tue Jan 12, 2010 6:01 pm
by ier
hey I've got an idea.
I have the idea.
to make highscores.php
I have all a version but this one is not good.
I should type everything in my own but this is stupid i gif you my version of highscores.php

Code: Select all

<?php
include_once 'connect.php';
  session_start();
    include_once 'logo.php';
    ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not logged in <br><br> <a href='login.php'>Login</a>";
  exit;
}
echo "<br>";
echo "<a href='index.php'>Go Home.</a><br>";
echo "<a href='battle.php'>Or Go Battle</a><br>";
$playerinfo ="select * from players where name = 'brandon'";
$playerinfo2 = mysql_query($playerinfo) or die ("could not select players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "brandon's attack is " . $playerinfo3['attack'];
echo "<br>brandon's defense is " . $playerinfo3['defense'];
echo "<br>brandon's hitpoint are ". $playerinfo3['hpoints'];
echo "<br>brandon's level is ". $playerinfo3['level'];
echo "<br><br>";
$playerinfo ="select * from players where name = 'ier'";
$playerinfo2 = mysql_query($playerinfo) or die ("could not select players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "ier's attack is " . $playerinfo3['attack'];
echo "<br>ier's defense is " . $playerinfo3['defense'];
echo "<br>ier's hitpoint are ". $playerinfo3['hpoints'];
echo "<br>iers's level is ". $playerinfo3['level'];
echo "<br><br>";
$playerinfo ="select * from players where name = 'berowe'";
$playerinfo2 = mysql_query($playerinfo) or die ("could not select players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "berowe's attack is " . $playerinfo3['attack'];
echo "<br>berowe's's defense is " . $playerinfo3['defense'];
echo "<br>berowe's hitpoint are ". $playerinfo3['hpoints'];
echo "<br>berowe's level is ". $playerinfo3['level'];
echo "<br><br>";
$playerinfo ="select * from players where name = 'test'";
$playerinfo2 = mysql_query($playerinfo) or die ("could not select players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "test's attack is " . $playerinfo3['attack'];
echo "<br>test's defense is " . $playerinfo3['defense'];
echo "<br>test's hitpoint are ". $playerinfo3['hpoints'];
echo "<br>test's level is ". $playerinfo3['level'];
?>

Re: Video #18

Posted: Tue Jan 12, 2010 9:29 pm
by ZeroComp
Yes the code is correct but if you want to publish the game it only lists just those names so say someone surpasses you by a level, it would just still list your name, so you need to probably add onto the code a bit if you really want to make it an updating highscore

Re: Video #18

Posted: Wed Jan 13, 2010 6:04 am
by ier
ow oké

Re: Video #18

Posted: Sat Jan 16, 2010 10:46 pm
by darspire
im haveing troubles with 3 pages =[. statpanel.php, weaponshop.php, and armorshop.php

Re: Video #18

Posted: Sun Jan 17, 2010 12:22 am
by ZeroComp
post your code and what errors your getting. the way your saying it is very unclear

Re: Video #18

Posted: Sun Jan 17, 2010 2:01 am
by darspire
statpanel:Notice: Use of undefined constant level - assumed 'level' in C:\wamp\www\tutorial\statpanel.php on line 22

Notice: Use of undefined constant level - assumed 'level' in C:\wamp\www\tutorial\statpanel.php on line 22

Notice: Use of undefined constant exper - assumed 'exper' in C:\wamp\www\tutorial\statpanel.php on line 23

Code: Select all

<div id="lpanel">
<?php
echo "<u><b> " . $playerinfo3['name'] . "</b></u><br>";
echo $playerinfo3['pclass'] . "<br>";
//////////////new for 17
echo "Level " . $playerinfo3['level'] . "<br>";



echo "Attack = " . $playerinfo3['attack'] . "<br>";
echo "Defense = " . $playerinfo3['defense'] . "<br>";
echo "Hit Points<br>";
echo "Spell Points<br><br>";
echo "<b><big><u>Gold</u></big></b><br>";
echo $playerinfo3['gold'];
?>
<?php
echo "<br><br>";
echo "<a href='equipment.php'>Equipment<br></a>";
////////////////////////new for video 17////////////////
echo"<br>";
 $expneeded = ($playerinfo3[level] * 100) * $playerinfo3[level];
  if ($playerinfo3[exper] >= $expneeded)
 {	echo "<br><a href='levelup.php'>Level Up!!</a>";}
?>
</div>


<div id= "hpointsback">
<?php
echo "<img src='images/barback.png'>";
?>
</div>

<div id= "hpoints">
<?php
$width = ($playerinfo3['hpoints'] / $playerinfo3['maxhp']) * 100;
echo "<img src='images/hpoints.png' width='$width' height='15' >";
?>
</div>

<div id= "spointsback">
<?php
echo "<img src='images/barback.png'>";
?>
</div>

<div id= "spoints">
<?php
$width = ($playerinfo3['spoints'] / $playerinfo3['maxspoints']) * 100;
echo "<img src='images/spoints.png' width='$width' height='15' >";
?>
</div>

weaponshop:Notice: Undefined variable: bypass in C:\wamp\www\tutorial\weaponshop.php on line 94


Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\weaponshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\weaponshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\weaponshop.php on line 119

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?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';
?>
</div>
<div id="table">
 <?php
 $pllocation=$playerinfo3['location'];
//////////////////////////new for video 18/////////////
 $inninfo="SELECT * from locations where location='$pllocation' AND type='weaponshop'";
$inninfo2=mysql_query($inninfo) or die("could not get player stats!");
$inninfo3=mysql_fetch_array($inninfo2);
 
 if (isset($_GET['bought']))
 {
 $bypass = 1;
  $id=$_GET['id'];
 
 $playerid = $playerinfo3['id'];
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];

$iteminfo="SELECT * from weapons where id='$id'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);

if ($playerinfo3['gold'] < $iteminfo3['price'])
{
 echo "You do not have enough Gold for this purchase!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}


if ($playerinfo3['pclass'] != $iteminfo3['class'] && $iteminfo3['class'] != "any")
{
 echo "You are not the right class for this item!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}

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



$name = $iteminfo3['name'];
$rating = $iteminfo3['rating'];
$wlevel = $iteminfo3['level'];
$hittext = $iteminfo3['hittext'];
$damage = $iteminfo3['damage'];
$randid = rand(1000,999999999);

$percentage = $iteminfo3[price] / 100;
	  $price = $iteminfo3[price] * $percentage;
      $newprice = $price + $iteminfo3[price];
	  $newprice = (int)$newprice;

$itembought = "INSERT into playerweapons(pid, name, rating, level, randid,price,class,hittext,damage) VALUES ('$playerid','$name','$rating','$wlevel','$randid','$newprice','$class','$hittext','$damage')";
mysql_query($itembought) or die("could not insert weapon into backpack");

$updateplayer="update players set gold=gold-'$newprice' where name='$player'";
  mysql_query($updateplayer) or die("Could not update player");

echo $name . " Purchased<br>";
echo $inninfo3['exitgreet'] . "<br>";
 echo "<a href='index.php'>Go Back</center>";
  
 }
 
 
 
 if ($bypass != 1)
 {
$counter = 0;
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];




  echo "<center>" . $inninfo3['greeting'] . "<br>";
 echo "<small>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $invinfo="SELECT * from weapons where class = '$class' AND level <= '$level' || class='any'";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Rating<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
	  $percentage = $invinfo3[price] / 100;
	  $price = $invinfo3[price] * $percentage;
      $newprice = $price + $invinfo3[price];
	  $newprice = (int)$newprice;

      print "<tr><td>$invinfo3[name]</td><td>$invinfo3[rating]</td><td>$newprice</td><td><A href='weaponshop.php?id=$invinfo3[id]&bought=1'>Buy Weapon</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='index.php'>Go Back</center>";
            exit;
      }
  echo "<center><a href='index.php'>NeverMind</center></a>";
  }
  ?>
  </div>

armorshop:Notice: Undefined variable: bypass in C:\wamp\www\tutorial\armorshop.php on line 97


Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?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';
?>
</div>
<div id="table">
 <?php
$counter = 0;
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];
$pllocation=$playerinfo3['location'];
//////////////////////////new for video 18/////////////
 $inninfo="SELECT * from locations where location='$pllocation' AND type='armorshop'";
$inninfo2=mysql_query($inninfo) or die("could not get player stats!");
$inninfo3=mysql_fetch_array($inninfo2);
 
 if (isset($_GET['bought']))
 {
 $bypass = 1;
 
  $id=$_GET['id'];


$playerid = $playerinfo3['id'];
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];

$iteminfo="SELECT * from armor where id='$id'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);

if ($playerinfo3['gold'] < $iteminfo3['price'])
{
 echo "You do not have enough Gold for this purchase!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}


if ($playerinfo3['pclass'] != $iteminfo3['class'] && $iteminfo3['class'] != "any")
{
 echo "You are not the right class for this item!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}

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



$name = $iteminfo3['name'];
$rating = $iteminfo3['rating'];
$wlevel = $iteminfo3['level'];
$location = $iteminfo3['location'];
$randid = rand(1000,999999999);

$percentage = $iteminfo3[price] / 100;
	  $price = $iteminfo3[price] * $percentage;
      $newprice = $price + $iteminfo3[price];
	  $newprice = (int)$newprice;

$itembought = "INSERT into playerarmor(pid, name, rating, level, randid,price,class,location) VALUES ('$playerid','$name','$rating','$wlevel','$randid','$newprice','$class','$location')";
mysql_query($itembought) or die("could not insert weapon into backpack");

$updateplayer="update players set gold=gold-'$newprice' where name='$player'";
  mysql_query($updateplayer) or die("Could not update player");

echo $name . " Purchased";
echo $inninfo3['exitgreet'] . "<br>";
 echo "<a href='index.php'>Go Back</center>";
}



 if ($bypass != 1)
 {
 echo "<center>" . $inninfo3['greeting'] . "<br>";


 echo "<small>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $invinfo="SELECT * from armor where class = '$class' AND level <= '$level' || class='any'";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Rating<font color='ffffff'>______</td><td>Location<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
	  /////////////////////new for video 18//////////////////////
	  $percentage = $inninfo3[price] / 100;
	  $price = $invinfo3[price] * $percentage;
      $newprice = $price + $invinfo3[price];
	  $newprice = (int)$newprice;
	  print "<tr><td>$invinfo3[name]</td><td>$invinfo3[rating]</td><td>$invinfo3[location]</td><td>$newprice</td><td><A href='armorshop.php?id=$invinfo3[id]&bought=1'>Buy Armor</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='index.php'>Go Back</center>";
            exit;
      }
  echo "<center><a href='index.php'>NeverMind</center></a>";
  }
  ?>
  </div>

with weapon and armor shop, it just has an error for all items in the shop

Re: Video #18

Posted: Sun Jan 17, 2010 2:01 am
by darspire
statpanel:Notice: Use of undefined constant level - assumed 'level' in C:\wamp\www\tutorial\statpanel.php on line 22

Notice: Use of undefined constant level - assumed 'level' in C:\wamp\www\tutorial\statpanel.php on line 22

Notice: Use of undefined constant exper - assumed 'exper' in C:\wamp\www\tutorial\statpanel.php on line 23

Code: Select all

<div id="lpanel">
<?php
echo "<u><b> " . $playerinfo3['name'] . "</b></u><br>";
echo $playerinfo3['pclass'] . "<br>";
//////////////new for 17
echo "Level " . $playerinfo3['level'] . "<br>";



echo "Attack = " . $playerinfo3['attack'] . "<br>";
echo "Defense = " . $playerinfo3['defense'] . "<br>";
echo "Hit Points<br>";
echo "Spell Points<br><br>";
echo "<b><big><u>Gold</u></big></b><br>";
echo $playerinfo3['gold'];
?>
<?php
echo "<br><br>";
echo "<a href='equipment.php'>Equipment<br></a>";
////////////////////////new for video 17////////////////
echo"<br>";
 $expneeded = ($playerinfo3[level] * 100) * $playerinfo3[level];
  if ($playerinfo3[exper] >= $expneeded)
 {	echo "<br><a href='levelup.php'>Level Up!!</a>";}
?>
</div>


<div id= "hpointsback">
<?php
echo "<img src='images/barback.png'>";
?>
</div>

<div id= "hpoints">
<?php
$width = ($playerinfo3['hpoints'] / $playerinfo3['maxhp']) * 100;
echo "<img src='images/hpoints.png' width='$width' height='15' >";
?>
</div>

<div id= "spointsback">
<?php
echo "<img src='images/barback.png'>";
?>
</div>

<div id= "spoints">
<?php
$width = ($playerinfo3['spoints'] / $playerinfo3['maxspoints']) * 100;
echo "<img src='images/spoints.png' width='$width' height='15' >";
?>
</div>

weaponshop:Notice: Undefined variable: bypass in C:\wamp\www\tutorial\weaponshop.php on line 94


Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\weaponshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\weaponshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\weaponshop.php on line 119

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?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';
?>
</div>
<div id="table">
 <?php
 $pllocation=$playerinfo3['location'];
//////////////////////////new for video 18/////////////
 $inninfo="SELECT * from locations where location='$pllocation' AND type='weaponshop'";
$inninfo2=mysql_query($inninfo) or die("could not get player stats!");
$inninfo3=mysql_fetch_array($inninfo2);
 
 if (isset($_GET['bought']))
 {
 $bypass = 1;
  $id=$_GET['id'];
 
 $playerid = $playerinfo3['id'];
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];

$iteminfo="SELECT * from weapons where id='$id'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);

if ($playerinfo3['gold'] < $iteminfo3['price'])
{
 echo "You do not have enough Gold for this purchase!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}


if ($playerinfo3['pclass'] != $iteminfo3['class'] && $iteminfo3['class'] != "any")
{
 echo "You are not the right class for this item!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}

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



$name = $iteminfo3['name'];
$rating = $iteminfo3['rating'];
$wlevel = $iteminfo3['level'];
$hittext = $iteminfo3['hittext'];
$damage = $iteminfo3['damage'];
$randid = rand(1000,999999999);

$percentage = $iteminfo3[price] / 100;
	  $price = $iteminfo3[price] * $percentage;
      $newprice = $price + $iteminfo3[price];
	  $newprice = (int)$newprice;

$itembought = "INSERT into playerweapons(pid, name, rating, level, randid,price,class,hittext,damage) VALUES ('$playerid','$name','$rating','$wlevel','$randid','$newprice','$class','$hittext','$damage')";
mysql_query($itembought) or die("could not insert weapon into backpack");

$updateplayer="update players set gold=gold-'$newprice' where name='$player'";
  mysql_query($updateplayer) or die("Could not update player");

echo $name . " Purchased<br>";
echo $inninfo3['exitgreet'] . "<br>";
 echo "<a href='index.php'>Go Back</center>";
  
 }
 
 
 
 if ($bypass != 1)
 {
$counter = 0;
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];




  echo "<center>" . $inninfo3['greeting'] . "<br>";
 echo "<small>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $invinfo="SELECT * from weapons where class = '$class' AND level <= '$level' || class='any'";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Rating<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
	  $percentage = $invinfo3[price] / 100;
	  $price = $invinfo3[price] * $percentage;
      $newprice = $price + $invinfo3[price];
	  $newprice = (int)$newprice;

      print "<tr><td>$invinfo3[name]</td><td>$invinfo3[rating]</td><td>$newprice</td><td><A href='weaponshop.php?id=$invinfo3[id]&bought=1'>Buy Weapon</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='index.php'>Go Back</center>";
            exit;
      }
  echo "<center><a href='index.php'>NeverMind</center></a>";
  }
  ?>
  </div>

armorshop:Notice: Undefined variable: bypass in C:\wamp\www\tutorial\armorshop.php on line 97


Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 116

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 117

Notice: Use of undefined constant price - assumed 'price' in C:\wamp\www\tutorial\armorshop.php on line 118

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?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';
?>
</div>
<div id="table">
 <?php
$counter = 0;
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];
$pllocation=$playerinfo3['location'];
//////////////////////////new for video 18/////////////
 $inninfo="SELECT * from locations where location='$pllocation' AND type='armorshop'";
$inninfo2=mysql_query($inninfo) or die("could not get player stats!");
$inninfo3=mysql_fetch_array($inninfo2);
 
 if (isset($_GET['bought']))
 {
 $bypass = 1;
 
  $id=$_GET['id'];


$playerid = $playerinfo3['id'];
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];

$iteminfo="SELECT * from armor where id='$id'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);

if ($playerinfo3['gold'] < $iteminfo3['price'])
{
 echo "You do not have enough Gold for this purchase!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}


if ($playerinfo3['pclass'] != $iteminfo3['class'] && $iteminfo3['class'] != "any")
{
 echo "You are not the right class for this item!";
  echo "<center><a href='index.php'>Go Back</center>";
  exit;
}

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



$name = $iteminfo3['name'];
$rating = $iteminfo3['rating'];
$wlevel = $iteminfo3['level'];
$location = $iteminfo3['location'];
$randid = rand(1000,999999999);

$percentage = $iteminfo3[price] / 100;
	  $price = $iteminfo3[price] * $percentage;
      $newprice = $price + $iteminfo3[price];
	  $newprice = (int)$newprice;

$itembought = "INSERT into playerarmor(pid, name, rating, level, randid,price,class,location) VALUES ('$playerid','$name','$rating','$wlevel','$randid','$newprice','$class','$location')";
mysql_query($itembought) or die("could not insert weapon into backpack");

$updateplayer="update players set gold=gold-'$newprice' where name='$player'";
  mysql_query($updateplayer) or die("Could not update player");

echo $name . " Purchased";
echo $inninfo3['exitgreet'] . "<br>";
 echo "<a href='index.php'>Go Back</center>";
}



 if ($bypass != 1)
 {
 echo "<center>" . $inninfo3['greeting'] . "<br>";


 echo "<small>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $invinfo="SELECT * from armor where class = '$class' AND level <= '$level' || class='any'";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Rating<font color='ffffff'>______</td><td>Location<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
	  /////////////////////new for video 18//////////////////////
	  $percentage = $inninfo3[price] / 100;
	  $price = $invinfo3[price] * $percentage;
      $newprice = $price + $invinfo3[price];
	  $newprice = (int)$newprice;
	  print "<tr><td>$invinfo3[name]</td><td>$invinfo3[rating]</td><td>$invinfo3[location]</td><td>$newprice</td><td><A href='armorshop.php?id=$invinfo3[id]&bought=1'>Buy Armor</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='index.php'>Go Back</center>";
            exit;
      }
  echo "<center><a href='index.php'>NeverMind</center></a>";
  }
  ?>
  </div>

with weapon and armor shop, it just has an error for all items in the shop

Re: Video #18

Posted: Sun Jan 17, 2010 2:10 am
by ZeroComp
go on those lines and change this [level] to this ['level'] very simple