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 where name='$player' and '$password'";
should be

Code: Select all

$query = "select name,password where name='$player' and password = '$password'";
change your () to {}

Code: Select all

$result = mysql_query ($query) or die ("could not query players");
$result2 = mysql_fetch_array ($result);
if ($result2)
(
should be

Code: Select all

$result = mysql_query ($query) or die ("could not query players");
$result2 = mysql_fetch_array ($result);
if ($result2)
{
and so on
Jake143
Posts: 3
Joined: Mon Jan 18, 2010 5:12 pm

Re: Video#5

Post by Jake143 »

thanks but now i getting parse error on line 23
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

repost your code so we can see the updated version.
SpikedRocker
Posts: 4
Joined: Tue Jan 19, 2010 7:55 pm

Re: Video#5

Post by SpikedRocker »

Loving this video series. I am having a simular issue as the other guy that had the blank page show up but the fixes submitted here don't seem to help. I've copied my code and posted it up on my paste bin page: http://abscured-vision-public.pastebin.com I have the authenticate, login, connect and battle php's up there now. Pretty much after login it sits there and shows authenticate.php?player=SpikedRocker&password=*****&submit=Login

I am running this on my webserver so thats why the connect looks the way it does as I've changed my info there. I'll forge forward to the next video but I'd like to know why this didn't work for me. I've probably overlooked something but more eyes on it the better. Thanks for the help.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Video#5

Post by Jackolantern »

Have you run test pages on your development server so you know it is configured correctly and running PHP?
The indelible lord of tl;dr
SpikedRocker
Posts: 4
Joined: Tue Jan 19, 2010 7:55 pm

Re: Video#5

Post by SpikedRocker »

Yes, it worked right up till this tutorial. I ran the last one battle.php tutorial pretty well with little issues.

I've set up http://www.abscuredvision.com/test/testconnect.php to confirm that my database is working fine. Should see my e-mail and the user id simular to the early tutorials.
Last edited by SpikedRocker on Wed Jan 20, 2010 3:13 am, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

authenticate.php?player=SpikedRocker&password=*****&submit=Login

why is it using GET method for authenticate?

should be a POST method
SpikedRocker
Posts: 4
Joined: Tue Jan 19, 2010 7:55 pm

Re: Video#5

Post by SpikedRocker »

Thats what I was thinking but everything I see has POST on it. I've even tried deleting the user and re-registering. The user is there.
User avatar
Zerk
Posts: 58
Joined: Wed Jan 20, 2010 2:59 am

Re: Video#5

Post by Zerk »

I've checked my Authenticate page, login page, and battle page multiple times and they all look like yours; however, it says I'm not logged in.

After I log in I get:

Code: Select all

Logged in successfully
Continue
But when I hit continue, sending me to battle.php, it says:

Code: Select all

not Logged in

Login
These are my code pages:

Code: Select all

Authenticate.php
<?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>";
  }
}

?>

Code: Select all

Battle.php
<?php
include_once 'connect.php';
session_start();

if (isset($_SESSION['palyer']))
{
  $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!";

?>

Code: Select all

Login.php
<form method="POST" action="authenticate.php">
User Name: <input type="text" name="player" size="21"><br />
Password: <input type="password" name="password" size="21" mask="x"><br />
<input type="submit" value="Login" name="submit">
</form>
lol...
Coding - Unity3d JS, PHP, and small amount of C#.
Art stuff - GIMP, Blender
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Video#5

Post by ZeroComp »

if (isset($_SESSION['palyer']))
theres your problem :)
battle.php line 5
Last edited by ZeroComp on Wed Jan 20, 2010 3:48 am, edited 1 time in total.
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Post Reply

Return to “Older Browser MMO Videos”