Browser MMO Video #5

Location of the Videos
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

Code: Select all

$query="select name,password from players where name= '$player' and '$password'";
should be

Code: Select all

$query="select name,password from players where name= '$player' and password='$password'";
jskinman
Posts: 56
Joined: Mon Mar 22, 2010 10:21 pm

Re: Video#5

Post by jskinman »

thanx :lol:
scape1027
Posts: 18
Joined: Sun Apr 18, 2010 2:33 pm

battle.php code

Post by scape1027 »

what is the code for BATTLE.PHP?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

I stopped posting source for videos under 10. It is easier for everyone to watch at least to 10, I recommend watching until 14 or so then work with the code. Has nothing to do with learning abilities or anything, just easier to watch the early videos.
scape1027
Posts: 18
Joined: Sun Apr 18, 2010 2:33 pm

Re: Video#5

Post by scape1027 »

hallsofvallhalla wrote:I stopped posting source for videos under 10. It is easier for everyone to watch at least to 10, I recommend watching until 14 or so then work with the code. Has nothing to do with learning abilities or anything, just easier to watch the early videos.

well you see, when i log in, it says "Successfully Logged in" or something, and when I hit continue to go to the battle thing (video 5) it says

"Parse error: parse error in C:\wamp\www\tutorial\battle.php on line 7"

do you know whats wrong? and heres my code for lines 1 to 56

<?php
include '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);

$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>";

///////creature info
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!";

?>
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Video#5

Post by Jackolantern »

It looks like your first if block is using parenthesis to create the block instead of brackets. Change:

Code: Select all

<?php
include '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);

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

Code: Select all

<?php
include 'connect.php';
session_start();

if (isset($_SESSION['player'])) //looks like you need to add the underscore here, too
{                                           //change to bracket. Parenthesis don't work here. 
     $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);

$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
The indelible lord of tl;dr
scape1027
Posts: 18
Joined: Sun Apr 18, 2010 2:33 pm

Re: Video#5

Post by scape1027 »

k thanks
scape1027
Posts: 18
Joined: Sun Apr 18, 2010 2:33 pm

Re: Video#5

Post by scape1027 »

urmo252
Posts: 1
Joined: Mon May 03, 2010 12:34 am

Re: Video#5

Post by urmo252 »

I have 3 errors:( u can help me!!
Pictures:
Image
Image
Image


Code:
authenticate.php

Code: Select all

<?php
include_once 'coonetct.php';
session_start();

if (isset($_POST['submit']))
(
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$player=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>";
)
)
?>


attack.php

Code: Select all

<?php
include 'connect.php';
session_start();

if (isset($SESSION['player']))
(
$player1=$_SESSION['player1'];
)
else
(
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
)
$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 creatures where name = '$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);

battle.php

Code: Select all

<?php
include 'connect.php';
session_start();

if (isset($SESSION['player']))
(
$player1=$_SESSION['player1'];
)
else
(
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
)
$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

$playerhp = $playerinfo3['htpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

you ( ) are wrong should be { }

parentheses should be used in the if statement like

Code: Select all

if ($this == $that)
{


}
code blocks are used after that
Post Reply

Return to “Older Browser MMO Videos”