Browser MMO Video #3

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

Re: Video#3

Post by hallsofvallhalla »

amen, a standard is the way to go.
stickandmove
Posts: 4
Joined: Tue Mar 02, 2010 7:56 am

Re: Video#3

Post by stickandmove »

Um just wanted to say thanks these tutorials are really helping me out alot.
i have one problem though i followed the instructions on the video but this has happened to show up in my register page and in the test page as well,
"Warning: include(connect.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\tutorial\register.php on line 2"

im not sure maybe i missed some thing or is that some kind or error.
Thanks for your time.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#3

Post by hallsofvallhalla »

are you sure you have it like this

Code: Select all

include 'connect.php';
and not like this

Code: Select all

include (connect.php);
by the way i recommend watching all the videos then trying to work with the files.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Video#3

Post by Jackolantern »

Also, if you write your include file that way, it must be in the same directory. So if you are trying to divide up your game between directories to keep it tidy (which is a good idea), you will need to direct PHP to the correct location of your connect.php file. Ideally, it is best to keep it out of your root folder and direct PHP to go up a directory or two to find it. That way it is not accessible through users of your web server under any situation. Something like this would work:

Code: Select all

include '../../connect/connect.php';
If placed in your root folder, that would tell PHP to go two directories above your root folder, into a folder called "connect" and in there it will find the connect.php file.
The indelible lord of tl;dr
stickandmove
Posts: 4
Joined: Tue Mar 02, 2010 7:56 am

Re: Video#3

Post by stickandmove »

thanks i found out what i was doing wrong, when i did the "test.php" page in the first part i over wrote it in the "connect.php" page so the "include 'connect.php' " didnt work. XD noob mistake srry for the bother lol
Mike9730
Posts: 24
Joined: Thu Mar 04, 2010 1:59 am

Re: Video#3

Post by Mike9730 »

Iam haveing an eror plz help it says not able to query for password evrey single time i try to register plz help

Code: Select all

<?php
include 'connect.php';
?>

<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);

if ($email == "")
{
echo "You didn't enter a email address!<br>";
echo " <A href='register.php'>Go back</a>";
    exit;
    }
if ($password==$pass2)
{
  
  $isplayer="SELECT * from players where name='$player'";
  $isplayer2=mysql_query($isplayer) or die("Could not query players table");
  $isplayer3=mysql_fetch_array($isplayer2);
  if(!$_POST['password'] || !$_POST['pass2'])
  {
     print "You did not enter a password";
    echo " <A href='register.php'>Go back</a><br>";
    exit;
  }
  else if($isplayer3 || strlen($player)>15 || strlen($player)<1)
  {
     print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter<br>";
     echo " <A href='register.php'>Go back</a>";
    exit;
  }
  else
  {
    $isaddress="SELECT * from players where email='$email'";
    $isaddress2=mysql_query($isaddress) or die("not able to query for password");
    $isaddress3=mysql_fetch_array($isaddress2);
    if($isaddress3)
    {
      print "There is already a player with that e-mail address<br>";
      echo " <A href='register.php'>Go back</a>";
    exit;
    }
    else
    {
        $password=md5($password);
        
$SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')"; 
      mysql_query($SQL) or die("could not register");
      
      print "Thank you for registering.";
   
    }
  }
}

else
{
  print "Your password didn't match or you did not enter a password<br>";
   echo " <A href='register.php'>Go back</a>";
    exit;
}
echo "<br><A href='login.php'>Login Page</a>";
?>
Last edited by Mike9730 on Fri Mar 05, 2010 12:36 am, edited 1 time in total.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Video#3

Post by Jackolantern »

Please post your reguser code. We can't really even guess what the problem is without seeing it.
The indelible lord of tl;dr
User avatar
FriendlyDragon
Posts: 2
Joined: Thu Mar 11, 2010 12:00 am

Re: Video#3

Post by FriendlyDragon »

First off I wanna say thanks for creating these videos... although I'm a bit stuck at the moment I have really enjoyed working through the first couple and am looking forward to continuing with them. So far I have been able to solve all the issues that I've come across by checking on here or by doing a quick google search, but now I have an issue with the 'reguser.php' code and I've got no idea what is causing it...

Basically, it is throwing up an error whenever I try creating a new user. Here is the error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\xampp\htdocs\BrowserBasedGame\reguser.php on line 57

I use notepad++ which says that line 57 of 'reguser.php' is:

$SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')";

I've looked over this line dozens of times, comparing it to the code in the video and here on the forum but I cannot see what the problem is. I'm a complete beginner with php to be honest... so hopefully the problem is more obvious to you guys. Any help or advice would be really appreciated.

Thanks.

Code: Select all

<?php
include 'connect.php';
?>

<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);

if ($email == "")
{
	echo "You didn't enter an email address<br>";
	echo "<A href='register.php>Back</a>";
	exit;
}

if ($password==$pass2)
{
	$isplayer="SELECT * from players where name='$player'";
	$isplayer2=mysql_query($isplayer) or die("could not query players table");
	$isplayer3=mysql_fetch_array($isplayer2);
	
	if(!$_POST['password'] || !$_POST['pass2'])
	{
		print "You didn't enter a password<br>";
		echo "<A href='register.php'>Back</a>";
		exit;
	}
	
	else if($isplayer3 || strlen($player)>21 || strlen($player)<1)
	{
		print "This name is already is use, or the name you 
		specified is over 21 letters or less than 1 letter<br>";
		echo "<A href='register.php'>Back</a>";
		exit;
	}
	
	else
	{
		$isaddress="SELECT * from players where email='$email'";
		$isaddress2=mysql_query($isaddress) or die("not able to query for address");
		$isaddress3=mysql_fetch_array($isaddress);
		
		if($isaddress3)
		{
			print "There is already a player with that e-mail address<br>";
			echo "<A href='register.php'>Back</a><br>;
			exit;
		}
		
		else
		{
			$password=md5($password);
			$SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')";
			mysql_query($SQL) or die("could not register");
			print "Thank you for registering!";
		}
	}
}
	
else
{
	print "Your password didn't match, or you did not enter a password<br>";
	echo "<A href='register.php'>Back</a><br>";
	exit;
}

echo "<A href="login.php">Login Page</a><br>";

?>
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Video#3

Post by Jackolantern »

Are you sure that those are the exact names of all of your fields in MySQL? I can't remember if that would generate that error or not.

It looks like you are copying the video tutorial code verbatim, and in that case, you cold just copy and paste the code from the video 3 thread (look right below the embedded video) into your script file. If you are still getting the error, it is likely something in your MySQL.

I say all this because I can't see the problem in your code. Maybe I am missing it, too, but it looks identical to Halls.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#3

Post by hallsofvallhalla »

yes that is weird. I always recommend you watch all the videos up to at least 14 then try the code.
Post Reply

Return to “Older Browser MMO Videos”