Videos 1-20

Location of the Videos
Post Reply
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: Videos 1-20

Post by alexander19 »

Change this :

Code: Select all

$SQL = "INSERT INTO players('name', 'email') VALUES ($player, $email )";
mysql_query($SQL) or die ("could not register");
To this:

Code: Select all

$SQL = "INSERT INTO players(name, email) VALUES ('$player', '$email' )";
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 »

Already tried did not work, anyways what i did now was completely reset the whole thing and set all the original files as they are in the tutorial folder as it should.

Guess what:
Doesnt work :S

So here is everything i got for register new user.

Register.php

Code: Select all

<?php
include 'connect.php';

?>

<form method ="post" action="reguser.php">
Type Username Here: <input type="text" name="player" size="21"><br>
Type Password Here: <input type="text" name="password" size "15"><br>
ReType Password Again: <input type="text" name="pass2" size "15"><br>
Type Email Address: <input type="text" name="email" size "60"><br>

<input type="submit" value="submit">
 

 <?php
      print "<select name='classchoice' length='20'>";
      $classinfo="SELECT * from classes";
      $classinfo2=mysql_query($classinfo) or die("Could not select classes");
      while ($classinfo3=mysql_fetch_array($classinfo2))
      {
        print "<option>$classinfo3[name]</option>";
      }
      print "</select><br>";
?>
</form>
<?php

      print "<center><h3>Class Starting modifiers</h3></center>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $selectclass="SELECT * from classes";
      $selectclass2=mysql_query($selectclass) or die("could not select Classes");
      print "<table border='1' bordercolor='black' bgcolor='#ffffff'>";
      print "<tr><td><font color='cc0033'>Class<font color='ffffff'>_____________</td><td><font color='cc0033'>Attack<font color='ffffff'>_</font><td><font color='cc0033'>Defense<font color='ffffff'>_</font></td><td><font color='cc0033'>Hit Points<font color='ffffff'>_</font></td><td><font color='cc0033'>Spell Points<font color='ffffff'>_</font></td></tr>";
      while($selectclass3=mysql_fetch_array($selectclass2))
      {
       print "<tr><td>$selectclass3[name]</td><td>$selectclass3[attack]</td><td>$selectclass3[defense]</td><td>$selectclass3[hpoints]</td><td>$selectclass3[spoints]</td></tr>";
          
      }
      print "</table>";
      print "</td></tr></table>";    
      print "</center>";
    
    
?>
Reguser.php

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, 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");

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>";
?>
connect.php <-- mind you i left out the pass ;) but it is there

Code: Select all

<?php

$db = mysql_connect("localhost","root","") or die("Could not connect to db");
if(!$db)
 die("no db");
if(!mysql_select_db("tutorial",$db))
 die("No Database Selected");
 
 ?>
alright so the above codes are the original codes given by the user who made them with these videos.

Now i am stunned by the fact if these dont even work, then where am i doing something wrong or am not looking.

PS:
Quick note.... i am using XAMPP as my native web server.
Image
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: Videos 1-20

Post by alexander19 »

Hmmm wierd stuff...I'm afraid I cant help you..maybe halls or someone else can give you some further hints.

P.S. I had wamp,and there were a few errors aswell which I couldnt understand but after I moved to a real host they dissapeared.
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

Ok i found something out wich i dunno if this is wrong or right...

i have added this or die(mysql_error()); instead of this or die("could not register");

And now i get the error Field 'gold' doesn't have a default value hmmm weird stuff as this should be NULL in the first place... might be a small thing but nevertheless worth a try

Alright i think i have figured it out.

As you can see in SQL.sql the default values of player inserts are none or NOT NULL but there are no defaults so the script cant see where to add or delete or even know what is the default value of any of those.

I am looking to sort this out and will post the result back asap.

EDIT AFTER REDONE tutorial.sql file players section.

Code: Select all

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

--
-- Table structure for table `players`
--

CREATE TABLE IF NOT EXISTS `players` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `name` varchar(21) NOT NULL,
  `email` varchar(55) NOT NULL,
  `level` smallint(3) NOT NULL,
  `exper` int(11) NOT NULL,
  `password` varchar(32) NOT NULL,
  `hpoints` mediumint(3) NOT NULL DEFAULT '0',
  `attack` mediumint(3) NOT NULL DEFAULT '0',
  `defense` mediumint(3) NOT NULL DEFAULT '0',
  `maxhp` int(6) NOT NULL DEFAULT '0',
  `spoints` int(6) NOT NULL DEFAULT '0',
  `maxspoints` mediumint(6) NOT NULL,
  `gold` int(11) NOT NULL DEFAULT '0',
  `creature` int(6) NOT NULL DEFAULT '0',
  `pclass` varchar(31) NOT NULL,
  `location` varchar(21) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `players`
--

INSERT INTO `players` (`id`, `name`, `email`, `level`, `exper`, `password`, `hpoints`, `attack`, `defense`, `maxhp`, `spoints`, `maxspoints`, `gold`, `creature`, `pclass`, `location`) VALUES
(6, 'halls', 'halls', 2, 140, '9d7f1b1e4bd4ec1d534770320ff2111b', 42, 7, 6, 50, 7, 40, 197, 10, 'Warrior', 'Fordale Woods');

-- --------------------------------------------------------
I have given them default values, now it works :D

Here is the line i used to debug and see what was wrong and why i could not register.

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, 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(mysql_error());

print "Thank you for registering!";
Have fun.
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Videos 1-20

Post by hallsofvallhalla »

because this is wrong

Code: Select all

$SQL = "INSERT INTO players('name', 'email') VALUES ($player, $email )";
mysql_query($SQL) or die ("could not register");
should be

Code: Select all

$SQL = "INSERT INTO players(name, email) VALUES ('$player', '$email')";
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 »

Problem has been solved, look at the post with values i set above yours val :) i added DEFAULTS to it :) and now it works perfectly.

Even the defaults are 0 they are still set correct by inserts for normal hp sp points.

So the first post with the tutorial.sql needs to be updated with the new player values :)
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Videos 1-20

Post by hallsofvallhalla »

i am not sure what you are saying. Nothing in my sql needs to be fixed. It works perfectly.
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

hallsofvallhalla wrote:i am not sure what you are saying. Nothing in my sql needs to be fixed. It works perfectly.
This is the original sql file given with the tutorial videos in first post.

Code: Select all

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

--
-- Table structure for table `players`
--

CREATE TABLE IF NOT EXISTS `players` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `name` varchar(21) NOT NULL,
  `email` varchar(55) NOT NULL,
  `level` smallint(3) NOT NULL,
  `exper` int(11) NOT NULL,
  `password` varchar(32) NOT NULL,
  `hpoints` mediumint(3) NOT NULL,
  `attack` mediumint(3) NOT NULL,
  `defense` mediumint(3) NOT NULL,
  `maxhp` int(6) NOT NULL,
  `spoints` int(6) NOT NULL,
  `maxspoints` mediumint(6) NOT NULL,
  `gold` int(11) NOT NULL,
  `creature` int(6) NOT NULL DEFAULT '0',
  `pclass` varchar(31) NOT NULL,
  `location` varchar(21) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `players`
--

INSERT INTO `players` (`id`, `name`, `email`, `level`, `exper`, `password`, `hpoints`, `attack`, `defense`, `maxhp`, `spoints`, `maxspoints`, `gold`, `creature`, `pclass`, `location`) VALUES
(6, 'halls', 'halls', 2, 140, '9d7f1b1e4bd4ec1d534770320ff2111b', 42, 7, 6, 50, 7, 40, 197, 10, 'Warrior', 'Fordale Woods');

-- --------------------------------------------------------
Now as you can see there are no defaults set for:

`hpoints` mediumint(3) NOT NULL DEFAULT '0',
`attack` mediumint(3) NOT NULL DEFAULT '0',
`defense` mediumint(3) NOT NULL DEFAULT '0',
`maxhp` int(6) NOT NULL DEFAULT '0',
`spoints` int(6) NOT NULL DEFAULT '0',
`gold` int(11) NOT NULL DEFAULT '0',
`location` varchar(21) NOT NULL DEFAULT '0',

When i did the reguser.php modification from: or die "Could not register user" to: or die mysql(error) to debug what was wrong with it, it gave me this error in value: there is no default value set for gold, hpoints etc etc, so i gave it a default value of DEFAULT '0' so now it see's the default as 0 and fills it in with the appropriate values given by registration form :)

Hope this clears up a few misunderstandings, sorry for my bad english.
Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Videos 1-20

Post by hallsofvallhalla »

i see, are you using wamp or something else. You don't need a default for those. They will already default to 0.

That is truly strange.
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: Videos 1-20

Post by Asgarth »

i am using XAMPP as this has more options in it then WAMP, before i used XAMPP i had DISKW but well anyways it is working now after i added them defaults.

Alright so now this was just a toturial based game right, so no expansions, no making further of this game, or is this like an ongoing tutorial for example: if anyone makes a chatbox or anything in it and add this with a howto or vid, then the tutorial game would be expanded as such.
Image
Post Reply

Return to “Older Browser MMO Videos”