Browser MMO Video #18

Location of the Videos
User avatar
sonicatu
Posts: 6
Joined: Tue Dec 22, 2009 11:16 am

Re: Video #18

Post 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 :)
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video #18

Post 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
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

Re: Video #18

Post 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'];
?>
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video #18

Post 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
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
User avatar
ier
Posts: 67
Joined: Sun Jan 10, 2010 7:32 pm

Re: Video #18

Post by ier »

ow oké
darspire
Posts: 194
Joined: Sat Jul 25, 2009 9:21 pm

Re: Video #18

Post by darspire »

im haveing troubles with 3 pages =[. statpanel.php, weaponshop.php, and armorshop.php
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video #18

Post by ZeroComp »

post your code and what errors your getting. the way your saying it is very unclear
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
darspire
Posts: 194
Joined: Sat Jul 25, 2009 9:21 pm

Re: Video #18

Post 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
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
darspire
Posts: 194
Joined: Sat Jul 25, 2009 9:21 pm

Re: Video #18

Post 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
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video #18

Post by ZeroComp »

go on those lines and change this [level] to this ['level'] very simple
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Post Reply

Return to “Older Browser MMO Videos”