Videos 1-20

Location of the Videos
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

Alright after been trough all the videos, and inported the db from the SQL provided with this tut, i have a little problem....

Everytime i try to register, it says could not register :P

I have looked trough the connect.php file = good
i have looked trough register.php = good
i have looked trough reguser.php and it gets stuck on this line...

Code: Select all

$SQL = "INSERT into players(name, password, email, level, exper, attack, defense, hpoints, maxhp, spoints, maxspoints,pclass) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]','$classquery3[name]')";
mysql_query($SQL) or die("could not register");
dunno but the whole db is setup good including the connect.php file
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Videos 1-20

Post by hallsofvallhalla »

double check that everything matches the DB, post your whole reguser.php code.
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

hallsofvallhalla wrote:double check that everything matches the DB, post your whole reguser.php code.
I have rechecked the whole thing and cant really find what is wrong :S

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);
$classchoice=$_POST['classchoice'];

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<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else if($isplayer3 || strlen($player)>21 || 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";
echo " <A href='register.php'>Go back</a><br>";
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";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
else
{
$password=md5($password);

 //////////////////////////////new for video 9//////////////
 $classquery="SELECT * from classes where name='$classchoice'";
  $classquery2=mysql_query($classquery) or die("Could not query classes");
  $classquery3=mysql_fetch_array($classquery2);

$SQL = "INSERT into players(name, email, level, exper, password, hpoints, attack, defense, maxhp, spoints, maxspoints, pclass) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]','$classquery3[name]')";
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";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
 echo " <A href='login.php'>Login Page</a><br>";
?>
I redid also the whole db sql install trough that file.

Anyways i will redo the whole game again following the videos, i might have overlooked something.
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Videos 1-20

Post by hallsofvallhalla »

ah i see the issue..look at the order of your insert and your values, you have name, email, level, then your values are player, then password, then email....line these up correctly.

Code: Select all

$SQL = "INSERT into players(name, email, level, exper, password, hpoints, attack, defense, maxhp, spoints, maxspoints, pclass) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]','$classquery3[name]')";
mysql_query($SQL) or die("could not register");
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

Gives me the same error, but i think i know what is wrong....

look at the inserts again and notice the brackets.

$classquery3[hpoints] <----- doesnt this have to be $classquery3['hpoints'] ;) so here is the whole sequence if this was wrong in the first place.

Code: Select all

$SQL = "INSERT into players(name, email, level, exper, password, hpoints, attack, defense, maxhp, spoints, maxspoints, pclass) VALUES ('$player','$password','$email','1','0','$classquery3['attack']','$classquery3['defense']','$classquery3['hpoints']','$classquery3['hpoints']','$classquery3['spoints']','$classquery3['spoints']','$classquery3['name']')";
mysql_query($SQL) or die("could not register");
Hope this is correct.

Wait i did it wrong grrrrr redo the above below here so it is stated 2x.

Code: Select all

$SQL = "INSERT into players(name, email, level, exper, password, hpoints, attack, defense, maxhp, spoints, maxspoints, pclass) VALUES ("$player","$password","$email","1","0","$classquery3['attack']","$classquery3['defense']","$classquery3['hpoints']","$classquery3['hpoints']","$classquery3['spoints']","$classquery3['spoints']","$classquery3['name']")";
mysql_query($SQL) or die("could not register");
OMG Now i dunno anymore grrr lemme check my own emu for the inserts

small insert of a monster for my java based emu

Code: Select all

INSERT INTO `npc` VALUES
(1,1,'Thomas D. Turkey',0,'Misguided Holiday Scrooge',0,'LineageMonster4.br_crazy_turkey',20.00,30.00,70,'male','L2Npc',40,3862,1494,0.00,0.00,40,43,30,21,20,20,0,0,1303,471,607,382,253,0,333,0,0,0,0,30,132,0,0,'LAST_HIT','false');
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Videos 1-20

Post by hallsofvallhalla »

$classquery3[hpoints] <----- doesnt this have to be $classquery3['hpoints'] ;) so here is the whole sequence if this was wrong in the first place.
no it should be

Code: Select all

$classquery3[hpoints]
also you still did not fix the order, look at it again
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

Ok yet again i have looked into this and found that in classes there are a few rows missing in the table.

I think because of that it cant be added as it is not stated in the first place.

maxhp
maxspoints
pclass

Are not in the database under Classes Table.

Here is the SQL Provided with the videos i have.

Code: Select all

-- --------------------------------------------------------

--
-- Table structure for table `classes`
--

CREATE TABLE IF NOT EXISTS `classes` (
  `name` varchar(30) NOT NULL,
  `attack` smallint(3) NOT NULL,
  `defense` smallint(3) NOT NULL,
  `hpoints` smallint(3) NOT NULL,
  `spoints` smallint(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `classes`
--

INSERT INTO `classes` (`name`, `attack`, `defense`, `hpoints`, `spoints`) VALUES
('Warrior', 8, 8, 15, 3),
('Wizard', 4, 4, 10, 15),
('Assassin', 5, 4, 10, 8),
('Knight', 5, 6, 12, 8);

-- --------------------------------------------------------
So even if the line states query table classes for the things it need, it cant find these as they are not located in the table.

Dunno if i am wrong.
Image
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: Videos 1-20

Post by alexander19 »

Nope,the database looks fine,you dont neeed to have a extra maxhp or maxspoints and neither pclass.
For instance you want to make a warrior character,so when you register it, the hpoints and maxhp tabs from the players table will get the value of the hpoints from the classes table,and the pclass will get the value of the name tab same for spoints and maxspoints...they will take the value of spoints.
So if you registered a warrior you will have on the start 15/15 hp.(the first 15 is the hpoints which will change its value most of the time when you get hit in combat or drink a potion,and the second 15 is the maxhp which will only increase when you increase in level ) .

And for the :

Code: Select all

$SQL = "INSERT into players(name, email, level, exper, password, hpoints, attack, defense, maxhp, spoints, maxspoints, pclass) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]','$classquery3[name]')";
mysql_query($SQL) or die("could not register");
As halls said,work our the order,it should be like:name-$player,email-$email,password-$password...and so on.
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

Ok so now i have tried something else wich obviously also did not work.

If i have an error regarding Registration i intend to cut back to the basics, so what i did was strip the whole SQL Insert thing to only player wich means that only the $player = name would be inserted into database.

Did not work neither while it is reading the database.

Ok little explenation what i did:

Code: Select all

 //////////////////////////////new for video 9//////////////
 $classquery="SELECT * from classes where name='$classchoice'";
  $classquery2=mysql_query($classquery) or die("Could not query classes");
  $classquery3=mysql_fetch_array($classquery2);

$SQL = "INSERT INTO players('name', 'email') VALUES ($player, $email )";
mysql_query($SQL) or die ("could not register");
The above should be obvious and should be working according to the file.
Sorry folks but this didnt work neither :S.

And as far as i know the order in wich things are made is not always trough to form, as long as you state where it has to be put.

Ok sorry for all this problems, but uhm as the basics not even work what the heck am i doing wrong :S
Image
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

Let me make me a cup of coffee :P might clear up my coding, just woke up ^^
Image
Post Reply

Return to “Older Browser MMO Videos”