Page 5 of 6

Re: Video #9

Posted: Thu Apr 22, 2010 1:18 am
by scape1027
ok, now i got a another problem....lol

when i go to my inventory, and i try using an item, i click USE ITEM and it dosent add anything....

it just stays the same!

thanks! here my code:

useitem.php

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;
    }

    $creature=$_GET['creature'];

    $playerinfo="SELECT * from players where name='$player'";
    $playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
    $playerinfo3=mysql_fetch_array($playerinfo2);

    $playerid = $playerinfo3['id'];

    $counter = 0;
    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 inventory where id='$playerid'";
          $invinfo2=mysql_query($invinfo) or die("could not select player inventory");
          print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
          print "<tr><td>Name<font color='ffffff'>________________</font></td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
          while($invinfo3=mysql_fetch_array($invinfo2))
          {
          print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td><A href='battle.php?randid=$invinfo3[randid]&creature=$creature'>Use Item</td></tr>";
           $counter = 1;

          }

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

          if ($counter == 0)
          {
                echo "<center>You have Nothing in your inventory!<br>";
                echo "<a href='battle.php?creature=$creature'>Go Back</center>";
                exit;
          }

        echo "<center><a href='battle.php?creature=$creature'>NeverMind</center>";

        ?>

Re: Video #9

Posted: Thu Apr 22, 2010 2:48 am
by Kirbie
scape1027 wrote:ok, now i got a another problem....lol

when i go to my inventory, and i try using an item, i click USE ITEM and it dosent add anything....

it just stays the same!

thanks! here my code:

useitem.php

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;
    }

    $creature=$_GET['creature'];

    $playerinfo="SELECT * from players where name='$player'";
    $playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
    $playerinfo3=mysql_fetch_array($playerinfo2);

    $playerid = $playerinfo3['id'];

    $counter = 0;
    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 inventory where id='$playerid'";
          $invinfo2=mysql_query($invinfo) or die("could not select player inventory");
          print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
          print "<tr><td>Name<font color='ffffff'>________________</font></td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td><font color='ffffff'>________________</td></tr>";
          while($invinfo3=mysql_fetch_array($invinfo2))
          {
          print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td><A href='battle.php?randid=$invinfo3[randid]&creature=$creature'>Use Item</td></tr>";
           $counter = 1;

          }

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

          if ($counter == 0)
          {
                echo "<center>You have Nothing in your inventory!<br>";
                echo "<a href='battle.php?creature=$creature'>Go Back</center>";
                exit;
          }

        echo "<center><a href='battle.php?creature=$creature'>NeverMind</center>";

        ?>
If you are refering to your attack and defense , I dont think its suppose to. I nocited the same thing. What kind of items are you refering to?

Re: Video #9

Posted: Thu Apr 22, 2010 2:49 am
by Kirbie
Jackolantern wrote:
Kirbie wrote:With the store issue

Have you created different location? The item can be in one store and not another.
Have you set up levels with you items? Make sure your character is correct level for the item. Make sure that your spelling is the same on all your items, pages, scripts, data bases, and make sure that you check your capitalazation is the same. I put everything in lower case until i get the script to work and then change 1 thing at a time until I know it works. Remember that "Warrior" is not the same as "warrior" in programing. I found that most of my problems were in my data bases and not the script.

Hope this helps
That is a pretty good error check list there 8-)
Learned the hard way :oops:

Re: Video #9

Posted: Thu Apr 22, 2010 7:43 pm
by scape1027
no, idk...like i am trying to buy a healing potion, to make my hitpoints more...and it is not using the item and making my hitpioints more....

Re: Video #9

Posted: Fri Apr 23, 2010 12:34 am
by hallsofvallhalla
i need to see battle.php

Re: Video #9

Posted: Sat Apr 24, 2010 1:00 am
by scape1027
i found out the problem

thanks!

it was in the database

Re: Video #9

Posted: Wed Jul 28, 2010 11:39 pm
by scotsmokin
first off thanks for all the work you have put in to the videos, great work learned loads from them
but i have a problem

been up dating as am going a long but now that whe have moved to classes and change this bit of code from

Code: Select all

$SQL = "INSERT into players(name, password, email, level, exper, attack, defence, hpoints, maxhp)
             VALUES 
            ('$player','$password','$email','1','0','5','5','30','30')";
to this

Code: Select all

$SQL = "INSERT into players(name, password, email, level, exper, attack, defence, hpoints, maxhp, spoints, maxspoints) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defence]','$classquery3[hpoints]','$classquery3[spoints]',
'$classquery3[maxspoints]')";
mysql_query($SQL) or die("could not register");
how do we now set the maxhp

Re: Video #9

Posted: Thu Jul 29, 2010 12:02 am
by scotsmokin
sat and reread all i could see

and chage it to this

Code: Select all


$classquery="SELECT * from classes where name='$classchoice'";
  $classquery2=mysql_query($classquery) or die("Could not query classes");
  $classquery3=mysql_fetch_array($classquery2);

$SQL = "INSERT into players(name, password, email, level, exper, attack, defence, hpoints, maxhp, spoints, maxspoints) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defence]','$classquery3[hpoints]','$classquery3[maxhp]','$classquery3[spoints]','$classquery3[maxspoints]')";
mysql_query($SQL) or die("could not register");

that seams to let me to let me register but
but what i set in the class does not transfer over to the players stats ie defence,hpoints,attack,spoints and things are set to 0
and not what ive set in the class fields

Re: Video #9

Posted: Thu Jul 29, 2010 7:22 am
by alexander19
If you dont have maxhpoints and maxspoints in your classes database table,just use $classquery3[hpoints] for both hpoints and maxhp and $classquery3[spoints] for spoints and maxspoints.
As long as your have your classes table filled up with all the info your $classchoice requires,dunno why it wouldn't work.

Re: Video #9

Posted: Thu Jul 29, 2010 4:10 pm
by scotsmokin
thanks for the help


been sitting looking at my classes tables and what i have is

Code: Select all


-- --------------------------------------------------------

--
-- Table structure for table `classes`
--

CREATE TABLE IF NOT EXISTS `classes` (
  `name` varchar(30) NOT NULL,
  `attack` smallint(3) NOT NULL,
  `defence` smallint(3) NOT NULL,
  `hpoints` smallint(3) NOT NULL,
  `spoints` int(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `classes`
--

INSERT INTO `classes` (`name`, `attack`, `defence`, `hpoints`, `spoints`) VALUES
('warrier', 8, 8, 15, 3),
('wizard', 4, 4, 10, 15),
('assasion', 5, 4, 10, 8),
('knight', 5, 6, 12, 8);
and in players i have

Code: Select all

CREATE TABLE IF NOT EXISTS `players` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `name` varchar(21) NOT NULL,
  `password` varchar(32) NOT NULL,
  `email` varchar(32) NOT NULL,
  `level` int(3) NOT NULL,
  `exper` int(11) NOT NULL,
  `attack` mediumint(3) NOT NULL,
  `defence` mediumint(3) NOT NULL,
  `hpoints` mediumint(3) NOT NULL,
  `maxhp` int(6) NOT NULL,
  `spoints` int(6) NOT NULL,
  `maxspoints` mediumint(6) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

--
-- Dumping data for table `players`
--

INSERT INTO `players` (`id`, `name`, `password`, `email`, `level`, `exper`, `attack`, `defence`, `hpoints`, `maxhp`, `spoints`, `maxspoints`) VALUES

(8, 'me', 'ab86a1e1ef70dff97959067b723c5c24', 'email', 1, 0, 0, 0, 0, 0, 0, 0),
(9, 'me', 'ab86a1e1ef70dff97959067b723c5c24', 'email', 1, 0, 0, 0, 0, 0, 0, 0);

so if i dont have maxhpoints and maxspoints in my classes table how would i set them in the players table


or could you explain a bit more thanks m8 as not to sure what you mean about using the same $classquery3 for both hpoints and maxhp