Browser MMO Video #5
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
correct. It is the errors that teach you to be a programmer, NOT the copying of code.
Re: Video#5
i noticed a small error in your code the part where you have
should be
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.
Code: Select all
$query = "select name,password from players where name='$player' and'$password'";
Code: Select all
$query = "select name,password from players where name='$player' and password='$password'";
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
Yes this has been over a few times. Has been a pain in my butt from the beginning.
Thanks for reporting.
Thanks for reporting.
Re: Video#5
Since this is such a common question - any way you can add an annotation to the video to let people know of the correction?
-
- Posts: 9
- Joined: Sat May 05, 2012 2:04 pm
-
- Posts: 9
- Joined: Sat May 05, 2012 2:04 pm
Re: Video#5
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
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
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
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.
I am working on getting all the source again. it is spread out.
-
- Posts: 9
- Joined: Sat May 05, 2012 2:04 pm
Re: Video#5
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!";
?>
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!";
?>
Re: Video#5
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:
<?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;
}