Browser MMO Video#11
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Video#11
I will have to review the code in a little bit for the error but here is video 14. It was on the second page.
The indelible lord of tl;dr
- Justeenoman
- Posts: 16
- Joined: Sun Aug 22, 2010 2:21 pm
Re: Video#11
Alright, thanks. Just post it once you are done. Thank you so much.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#11
then change this line
Code: Select all
$width = ($playerinfo3['hpoints'] / $playerinfo3['maxhp']) * 100;
Re: Video#11
hey halls i have a problem, whenever i create my username and password and email, it says you are now registered, but when i go to login it says the username or password you entered is incorrect, what am i doing wrong? i think its something wrong with my authenticate page. please take a look.
Code: Select all
<?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='$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='index.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#11
how many places have you posted this same problem? i answered one of them.
Re: Video#11
On video 11 now. I keep getting error.. Notice: Undefined variable: name in C:\wamp\www\battle.php on line 82
this is line 82.
$updateplayer="update players set creature='$cid' where name='$name'";
This is the whole code.
this is line 82.
$updateplayer="update players set creature='$cid' where name='$name'";
This is the whole code.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>Battle</title>
</head>
<body>
<?php
include_once 'connect.php';
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
print "<p>Not Logged In! <br /> <br /> <a href='login.php'>Log In</a></p>";
exit;
}
$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['randid']))
{
$randid=$_GET['randid'];
$iteminfo="SELECT * from inventory where randid='$randid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);
if (!$iteminfo3['name'])
{
}
else
{
$name = $iteminfo3['name'];
$stats = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];
if ($type == "healing")
{
$newhp = $statadd + $playerhp;
if ($newhp > $playerinfo3['maxhp'])
{
$newhp = $playerinfo3['maxhp'];
}
$updateplayer="update players set hpoints='$newhp' where name='$player'";
mysql_query($updateplayer) or die("could not update player!");
$updateitem="DELETE from inventory where name='$name' AND randid='$randid' limit 1";
mysql_query($updateitem) or die("could not delete item");
$playerhp = $newhp;
echo "Used " . $name . " and recovered " . $statadd . ".<br>";
}
}}
$creature = $playerinfo3['creature'];
if ($creature != 0)
{
$creatureinfo="SELECT * from creatures where id='$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 not get a creature");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
$cid=$creatureinfo3['id'];
$updateplayer="update players set creature='$cid' where name='$name'";
mysql_query($updateplayer) or die("Could not update player");
}
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
print "<p><u> " . $playerinfo3['name'] . "</u></p>";
print "<p>Hit Points = " . $playerhp . "</p>";
print "<p>Attack = " . $playerattack . "</p>";
print "<p>Defense = " . $playerdefense . "</p>";
print "<p><u> " . $creatureinfo3['name'] . "</u></p>";
print "<p>Hit Points = " . $creaturehp . "</p>";
print "<p>Attack = " . $creatureattack . "</p>";
print "<p>Defense = " . $creaturedefense . "</p>";
print "<p><a href='attack.php?creature=$creature'>Attack</a></p>";
print "<p><a href='useitem.php?creature=$creature'>Use Item</a></p>";
print "<p><a href='store.php?creature=$creature'>Go to Store</a></p>";
print "<p><a href='index1.php'>Exit Arena</a></p>";
print "<br><br><br><a href='logout.php'>Log Out</a>";
?>
</body>
</html>
Re: Video#11
Also getting multiple of the same error on different lines, in attack.php Notice: Undefined variable: creatureinfo3 in C:\wamp\www\attack.php on line 42,43,44,45,68,70,73,74.
here's my attack code.
here's my attack code.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>attack</title>
</head>
<body>
<?php
include_once 'connect.php';
session_start ();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
print "<p>Not Logged In! <br /> <br /> <a href='login.php'>Log In</a></p>";
exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats");
$playerinfo3=mysql_fetch_array($playerinfo2);
$creature = $playerinfo3['creature'];
if ($creature != 0)
{
$creatureinfo="SELECT * from creatures where id='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
print "<p><a href='battle.php'>No Creature Selected. Go Back!</a></p>";
}
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
print "<p><u> " . $playerinfo3['name'] . "'s Attack</u></p>";
$playerattack = rand(1,20) + $playerattack;
$creaturedefense = rand(1,20) + $creaturedefense;
echo "<p>" . $playerinfo3['name'] . "'s attack roll is " . $playerattack . "</p>";
echo "<p>" . $creature . "'s defense roll is " . $creaturedefense . "</p>";
if ($playerattack > $creaturedefense)
{
print "<p>" . $playerinfo3['name'] . " hits! </p>";
$playerdamage = rand(1,6);
$newcreaturehp = $creaturehp - $playerdamage;
print "<p>For " . $playerdamage . " points of damage! </p>";
if ($newcreaturehp < 1)
{
print "<p>the " . $creature . " has been killed</p>";
$updatecreature="DELETE from creatures where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
if ($playerinfo3['level'] > $creatureinfo3['level'])
{
$firstmod = $playerinfo3['level'] - $creatureinfo3['level'];
$secondmod = $firstmod * 10 ;
if ($secondmod > 90)($secondmod = 90);
$thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
$totalexper =$creatureinfo3['exper'] - $thirdmod;
}
else
{
$firstmod = $creatureinfo3['level'] - $playerinfo3['level'];
$secondmod = $firstmod *10 ;
if ($secondmod > 90)($secondmod = 90);
$thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
$totalexper =$creatureinfo3['exper'] * $thirdmod;
}
$totalexper = (int)$totalexper;
print "<br><b><big>You gain " . $totalexper . " experience.</b></big><br>";
$updateplayer="update players set exper=exper+'$totalexper',creature=0 where name='$player'";
mysql_query($updateplayer) or die("could not update player");
print "<p><a href='battle.php'>Go Back</a></p>";
exit;
}
$updatecreature="update creatures set hpoints='$newcreaturehp' where name='$creature'";
mysql_query($updatecreature) or die("could not update creature");
}
else
{
print "<p>" . $playerinfo3['name'] . " misses! </p>";
}
print "<p><u> " . $creature . "'s' Attack</u></p>";
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense;
echo "<p>" . $creature."'s attack roll is " . $creatureattack . "</p>";
echo "<p>" . $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "</p>";
if ($creatureattack > $playerdefense)
{
print "<p>" . $creature . " hits! </p>";
$creaturedamage = rand(1,6);
$newplayerhp = $playerhp - $creaturedamage;
print "<p>For " . $creaturedamage . " points of damage! </p>";
if ($newplayerhp < 1)
{
print "<p>" . $playerinfo3['name'] . " has been killed</p>";
print "<p><a href='gameover.php>Continue</a></p>";
exit;
}
$updateplayer="update players set hpoints='newplayerhp' where name='$player'";
mysql_query($updateplayer) or die("Could Not Update Player!");
}
else
{
print "<p>" . $creature . " misses!</p>";
}
print "<p><a href='battle.php?creature=$creature'>Battle Again!";
?>
</body>
</html>
Re: Video#11
MikeD i have the same problem like you with this $cid, but i tryed something, but still dk how fix it. U can try put same id (in db) for ur creature and player creature its workin then.
may some1 knows where is code error cuz it look alright, hmmm...
(i hate megaupdate... its not workin anymore and u cant checks urs codes with halls).
P.S. MikeD if u still need i can put here ma attack.php
may some1 knows where is code error cuz it look alright, hmmm...
(i hate megaupdate... its not workin anymore and u cant checks urs codes with halls).
P.S. MikeD if u still need i can put here ma attack.php
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#11
i am going to try to redo this series or at least get the source easier to grab and throw it on Udemy or somewhere else.