Browser MMO Video #5

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

Re: Video#5

Post by hallsofvallhalla »

correct. It is the errors that teach you to be a programmer, NOT the copying of code.
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: Video#5

Post by dust1031 »

i noticed a small error in your code the part where you have

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'";
if you left it as you typed it in it let you choose any password. like lets say my username is dust1031 and my real password is abc and someone has an account called test with the password 123 if i type in 123 for my password on dust1031 it would let me in. but if you put password='$password' it will stop it and if i get on dust1031 and type in 123 it would say incorrect username or password, i would have to type in abc to log in. thought i would point that out to everybody.
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

Yes this has been over a few times. Has been a pain in my butt from the beginning.


Thanks for reporting.
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Video#5

Post by OldRod »

Since this is such a common question - any way you can add an annotation to the video to let people know of the correction? :)
bradders0906
Posts: 9
Joined: Sat May 05, 2012 2:04 pm

Re: Video#5

Post by bradders0906 »

.
Last edited by bradders0906 on Sat May 05, 2012 2:12 pm, edited 1 time in total.
bradders0906
Posts: 9
Joined: Sat May 05, 2012 2:04 pm

Re: Video#5

Post by bradders0906 »

I keep getting this error when i try to test the authenticate.php

Parse error: syntax error, unexpected ';' in C:\wamp\www\tutorial\authenticate.php on line 7

please send me yours :S i dont know what ive done wrong :(
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#5

Post by hallsofvallhalla »

show us your authenticate.php so we can look at the problem.

I am working on getting all the source again. it is spread out.
bradders0906
Posts: 9
Joined: Sat May 05, 2012 2:04 pm

Re: Video#5

Post by bradders0906 »

see now, im not sure what i did but that problems fixed, when i try to log into my account and click continue im getting this message
Parse error: syntax error, unexpected ';' in C:\wamp\www\tutorial\battle.php on line 7

my battle.php is


<?php
include_once '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!";

?>
bradders0906
Posts: 9
Joined: Sat May 05, 2012 2:04 pm

Re: Video#5

Post by bradders0906 »

.
Zoo
Posts: 21
Joined: Tue Apr 17, 2012 6:38 pm

Re: Video#5

Post by Zoo »

try change something, cuz then u have "else" its working in {} for exemple, first check if code and if its not true check else..

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

[/quote]

should be:

Code: Select all

 if (isset($_SESSION['player']))
{
   $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in<br><br> <A href=' login.php'>Login</a>";
  exit;
}
Post Reply

Return to “Older Browser MMO Videos”