Page 12 of 35
					
				Re: Video#5
				Posted: Mon Jan 18, 2010 8:08 pm
				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
 
			
					
				Re: Video#5
				Posted: Tue Jan 19, 2010 5:33 pm
				by Jake143
				thanks but now i getting parse error on line 23
			 
			
					
				Re: Video#5
				Posted: Tue Jan 19, 2010 6:37 pm
				by hallsofvallhalla
				repost your code so we can see the updated version.
			 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 12:01 am
				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.
 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 1:42 am
				by Jackolantern
				Have you run test pages on your development server so you know it is configured correctly and running PHP?
			 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 2:53 am
				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.
 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 3:13 am
				by hallsofvallhalla
				authenticate.php?player=SpikedRocker&password=*****&submit=Login
why is it using GET method for authenticate?
should be a POST method
 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 3:21 am
				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.
			 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 3:40 am
				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:
But when I hit continue, sending me to battle.php, it says:
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...
 
			
					
				Re: Video#5
				Posted: Wed Jan 20, 2010 3:45 am
				by ZeroComp
				if (isset($_SESSION['palyer']))
theres your problem 

battle.php line 5