but im having problems, keep in mind this is the 1st time im making a shop by myself.
but heres what i got
basically i made a playerclass table in my DB, that shows what kind of classes people can buy. here are my fields
id
name
level
attack
defense
price
location
randid
amount
then i made another table and called it classbought that shows what classes people bought, here are my fields
pid
name
price
level
randid
attack
defense
equip
then i made 2 new .php scripts
called 1 buyclass.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
?>
<?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 id="table">
<?php
$class = $playerinfo3['pclass'];
$level = $playerinfo3['level'];
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['level'] < $iteminfo3['level'])
{
echo "You are not high enough level to use this item!";
echo "<center><a href='index.php'>Go Back</center>";
exit;
}
$itembought = "INSERT into classbought(pid, name, price level, randid,attack, defense,')
VALUES ('$playerid','$name','$price','$level','$randid','$attack','$defense')";
mysql_query($itembought) or die("could not insert class into backpack");
$updateplayer="update players set gold=gold-'$iteminfo3[price]' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
echo $name . " Purchased";
echo "<center><a href='index.php'>Go Back</center>";
?>
</div>
Code: Select all
<?php
include_once 'connect.php';
session_start();
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);
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 playerclass where amount > 0";
$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>Level<font color='ffffff'>______</td><td>Attack<font color='ffffff'>______</td><td>Defense<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td></tr>";
while($invinfo3=mysql_fetch_array($invinfo2))
{
$counter = 1;
print "<tr><td>$invinfo3[name]</td><td>$invinfo3[level]</td><td>$invinfo3[attack]</td><td>$invinfo3[defense]</td><td>$invinfo3[price]</td><td><A href='buyclass.php?randid=$invinfo3[randid]'>Buy Item</td></tr>";
}
print "</table>";
print "</td></tr></table>";
print "</center>";
echo "</small>";
{
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?'>Go Back</center>";
?>
( ! ) Notice: Undefined variable: iteminfo3 in C:\wamp\www\tutorial\buyclass.php on line 35
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: iteminfo3 in C:\wamp\www\tutorial\buyclass.php on line 47
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: playerid in C:\wamp\www\tutorial\buyclass.php on line 59
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: name in C:\wamp\www\tutorial\buyclass.php on line 59
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: price in C:\wamp\www\tutorial\buyclass.php on line 59
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: randid in C:\wamp\www\tutorial\buyclass.php on line 59
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: attack in C:\wamp\www\tutorial\buyclass.php on line 59
Call Stack
# Time Memory Function Location
1 0.0010 377624 {main}( ) ..\buyclass.php:0
( ! ) Notice: Undefined variable: defense in C:\wamp\www\tutorial\buyclass.php on line 59
how do i fix it, so i can buy classes, and also how can i make the attack and defense for the class, add to my current stats