i'm following hallsofvallhalla's tutorial to create a little Browser MMO..
which is kinda nice!
ok so i'm at the part 4b, and everything is right no error in the code and the page work...
but it seems as my creatures doesn't exist...
it say's "Player1" but do not say's creature name...............
A new Game Project has been started and is currently looking for coders &designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
<?php
include 'connect.php';
$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die("Could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
if (isset($_GET['creature']))
{
$creature=$_GET['creature'];
$creatureinfo="SELECT * from players where name='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("Could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
echo "<a href='battle.php>No Creature selected, go back.";
exit;
}
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
///////////////////player turn///////////////////////
echo "<u> " . $playerinfo3['name'] . "'s Attack</u><br>";
$playerattack = rand(1,20) + $playerattack;
$creaturedefense = rand(1,20) + $creaturedefense;
echo $playerinfo3['name'] . "'s Attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense . "<br>";
if($playerattack > $creaturedefense)
{
echo $playerinfo3['name'] . " hits! <br>";
$playerdamage = rand(1,6);
$newcreaturehp = $creaturehp - $playerdamage;
echo "For " . $playerdamage . " points of damage. <br>";
if ($newcreaturehp < 1)
{
echo "The " . $creature . " has been killed!";
$updatecreature="DELETE from creatures where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
echo "<a href='battle.php>Go back";
exit;
}
$updatecreature="update creatures set hpoints='$newcreaturehp' where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creatures");
}
else
{
echo $playerinfo3['name'] . " misses!<br>";
}
////////////////////////////creature turn/////////////////////////
echo "<u> " . $creature . "'s Attack</u><br>";
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense;
echo $creature . "'s Attack roll is " . $creatureattack . "<br>";
echo $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "<br>";
if($creatureattack > $playerdefense)
{
echo $creature . " hits! <br>";
$creaturedamage = rand(1,6);
$newplayerehp = $playerehp - $creaturedamage;
echo "For " . $creaturedamage . " points of damage. <br>";
if ($newplayerehp < 1)
{
echo $playerinfo3['name'] . " has been killed<br>";
echo "<a href='gameover.php>Continue";
exit;
}
$updateplayer="update players set hpoints='$newplayerhp' where name='player1'";
mysql_query($updateplayer) or die("Could not update player");
}
else
{
echo $creature . "misses!";
}
echo "<br><br><a href='battle.php?creature=$creature>Battle Again!";
?>
Also,
the "Battle Again" is not there...
why do you recommend me to start codes around video 14?
A new Game Project has been started and is currently looking for coders &designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
$creatureinfo="SELECT * from players where name='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("Could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
It looks like your trying to pull a creature from the players table.
Not sure how your DB is set up, but it should be something like this.
$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);
But it still dont show up the "battle again" option.
A new Game Project has been started and is currently looking for coders &designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and '$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<a href='battle.php'>Continue</a></big>>";
}
else
{
echo "<big>Wrong username or password, <a href='login.php'>Try Again</a></big>";
}
}
?>
A new Game Project has been started and is currently looking for coders &designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
A new Game Project has been started and is currently looking for coders &designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Fixed
i've forgot ")"...
i really like these tutorials as it helps me to learn a little bit.
A new Game Project has been started and is currently looking for coders &designers.
Here is the Topic: New Project
Or, just PM me if you're interested!