Page 34 of 35

Re: Video#5

Posted: Mon Oct 10, 2011 6:15 pm
by hallsofvallhalla
correct. It is the errors that teach you to be a programmer, NOT the copying of code.

Re: Video#5

Posted: Fri Oct 28, 2011 12:55 pm
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.

Re: Video#5

Posted: Fri Oct 28, 2011 1:49 pm
by hallsofvallhalla
Yes this has been over a few times. Has been a pain in my butt from the beginning.


Thanks for reporting.

Re: Video#5

Posted: Fri Oct 28, 2011 1:50 pm
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? :)

Re: Video#5

Posted: Sat May 05, 2012 2:09 pm
by bradders0906
.

Re: Video#5

Posted: Sat May 05, 2012 2:11 pm
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 :(

Re: Video#5

Posted: Sat May 05, 2012 2:59 pm
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.

Re: Video#5

Posted: Sat May 05, 2012 3:34 pm
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!";

?>

Re: Video#5

Posted: Sat May 05, 2012 3:44 pm
by bradders0906
.

Re: Video#5

Posted: Sat May 05, 2012 6:09 pm
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;
}