Attack page problem [solved]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
darklorda
Posts: 8
Joined: Thu Feb 23, 2012 8:49 am

Attack page problem [solved]

Post by darklorda »

Hi guyz.. i have a problem in battle.php .

Hit points =
Attack =
Defense =


goblin
Hit points = 5
Attack = 3
Defense = 3


Attack!

i don't see my stats why ?!? this is my code:


<?php
include 'connect.php';




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

$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];

if (isset($_GET['creature']))
{
$creature=$_GET['creature'];
$creatureinfo="SELECT * from creatures where name = '$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);

}
else
{
$creatureinfo="SELECT * from creatures order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die ("could get a creature!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}

$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];

/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";

///////creatureinfo
echo "<u> " . $creatureinfo3['name'] . "</u><br>";
echo "Hit points = " . $creaturehp . "<br>";
echo "Attack = " . $creatureattack . "<br>";
echo "Defense = " . $creaturedefense . "<br><br><br>";

echo "<a href='attack.php?creature=$creature'>Attack!";

?>

thank you
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Problem

Post by Chris »

Code: Select all

$playerinfo="SELECT * from players where name='player'"; 
Unless your name is 'player', that would be the reason why.

Code: Select all

$playerinfo="SELECT * FROM `players` WHERE `name`='". mysql_real_escape_string($_SESSION['player']) ."'"; 
Fighting for peace is declaring war on war. If you want peace be peaceful.
darklorda
Posts: 8
Joined: Thu Feb 23, 2012 8:49 am

Re: Problem

Post by darklorda »

mm no now
Notice: Undefined variable: _SESSION in C:\wamp\www\tutorial\battle.php on line 7

Hit points =
Attack =
Defense =


orc
Hit points = 10
Attack = 6
Defense = 6


Attack!

i use tutorial videos ..
darklorda
Posts: 8
Joined: Thu Feb 23, 2012 8:49 am

Re: Problem

Post by darklorda »

nvm i have just done it :P ty for help
Post Reply

Return to “Beginner Help and Support”