issues with the tutorial
issues with the tutorial
pretty sure it is me doing something wrong here but i have watched the tutorials up to adding images etc
however when i started to progress myself i have encountered a issue when registering a new player all the coding seems to be correct however it is not adding this to my players table in WAMP
can someone please help me with this?
Thank you
Edit: i also progressed further into the tutorial and came up with another error stating that the players stats could not be found i have got a feeling it is something to do with WAMP
anyone have any suggestions please
however when i started to progress myself i have encountered a issue when registering a new player all the coding seems to be correct however it is not adding this to my players table in WAMP
can someone please help me with this?
Thank you
Edit: i also progressed further into the tutorial and came up with another error stating that the players stats could not be found i have got a feeling it is something to do with WAMP
anyone have any suggestions please
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: issues with the tutorial
Can you post the entire script that is supposed to be putting the data into the database but isn't?
The stats not being found likely has to do with something not being entered into the database, like you mentioned.
The stats not being found likely has to do with something not being entered into the database, like you mentioned.
The indelible lord of tl;dr
Re: issues with the tutorial
and this<?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 player where name='$player'";
$isplayer2=mysql_query($isplayer) or die("Could not query player 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 player 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);
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>";
?>
<?php
include 'connect.php';
$playerinfo="SELECT * from player where name='player1";
$playerinfo2=mysql_query($playerinfo)or die ("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$playerhp = $playerinfo3['hpoints'];
$playerattak = $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 where fighting");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
$creatureinfo="SELECT * from creatures order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die("colud get a creature!");
$creatureifo3=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>";
echo "<a href='attack.php?creature=$creature'>Attack!";
?>
Re: issues with the tutorial
I'm sorry, I'm still new here, but which tutorial are you referring to? 
EDIT: Oh, of course found those awesome video tutorials. HERE
As for the code, you seem to be missing UPDATE and/or INSERT's from your code to be able to add stuff to your database.
I would guess at at this point, you are missing some code.

EDIT: Oh, of course found those awesome video tutorials. HERE
As for the code, you seem to be missing UPDATE and/or INSERT's from your code to be able to add stuff to your database.
I would guess at at this point, you are missing some code.
Code: Select all
else
{
$password = md5($password);
print "Thank you for registering!";
}
Why so serious?
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Re: issues with the tutorial
could it be this?
$SQL = "INSERT into players(name, password, email, level, exper, attack, defense, hpoints) VALUES ('$player','$password','$email','1','0','5','5','15',)";
mysql_query($SQL) or die("could not register");
this is just a quick type up so this may be incorrect just typing to input as you were correct there did not seem to be any code to tie in the php and the database together.
will have to check this evening will keep everyone posted incase anyone else enters this problem
$SQL = "INSERT into players(name, password, email, level, exper, attack, defense, hpoints) VALUES ('$player','$password','$email','1','0','5','5','15',)";
mysql_query($SQL) or die("could not register");
this is just a quick type up so this may be incorrect just typing to input as you were correct there did not seem to be any code to tie in the php and the database together.
will have to check this evening will keep everyone posted incase anyone else enters this problem
Re: issues with the tutorial
that looks like it,
just remember to have the execution of the query after that. (I might be stating the obvious but just making sure
)
EDIT: Oh sorry, you had it there already. Ignore my post.
just remember to have the execution of the query after that. (I might be stating the obvious but just making sure

Code: Select all
mysql_query($SQL) or die ("Something went wrong". mysql_error());
Why so serious?
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: issues with the tutorial
Correct you are missing the code to actually insert the player but seems like you got it.
Re: issues with the tutorial
ok just to give everyone a update i have rectified these issues and have progressed to the battle/attack php however getting to this point now i have come accross another error starting to think that i am useless at this here is the error:
Parse error: syntax error, unexpected ';' in C:\wamp\www\Tutorial\attack.php on line 13
if i remove the ; then i get this error instead:
Parse error: syntax error, unexpected '$creatureinfo' (T_VARIABLE) in C:\wamp\www\Tutorial\attack.php on line 14
here is my coding?
Kieron
Parse error: syntax error, unexpected ';' in C:\wamp\www\Tutorial\attack.php on line 13
if i remove the ; then i get this error instead:
Parse error: syntax error, unexpected '$creatureinfo' (T_VARIABLE) in C:\wamp\www\Tutorial\attack.php on line 14
here is my coding?
again thank you for you time and patience<?php
include 'connect.php';
$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
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
)
echo "<a href='battle.php'>No Creature selected. Go Back!";
exit;
)
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
///////////////////////players turn////////////////////
echo "<u> " . $playerinfo3['name'] . "'s Attack</u><br>";
$playerattack = rand(1,20) + $playerattack;
$creaturedefense = rand(1,20) + $creaturedefense;
echo $playerinfo3['name'] . "'s Attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense. "<br>";
if ($playerattack > $creaturedefense)
(
echo $playerinfo3['name'] . " hits! <br>";
$playerdamage = rand(1,6);
$newcreaturehp = $creaturehp - $playerdamage;
echo "For " . $playerdamage . " points of damage. <br>";
if ($newcreaturehp < 1)
(
echo "The " . $creature . " has been killed";
$updatecreature="DELETE from creatures where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
echo "<a href='battle.php>Go Back";
exit;
)
$updatecreature="update creatures set hpoints='$newcreaturehp' where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
)
else
(
echo $playerinfo3['name'] . " misses!<br>";
)
//////////////////////creatures turn //////////////////
echo "<u> " . $creature . "'s Attack</u><br>";
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense;
echo $creature . "'s Attack roll is " . $creatureattack . "<br>";
echo $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "<br>";
if ($creatureattack > $playerdefense)
(
echo $creature . " hits! <br>";
$creaturedamage = rand(1,6);
$newplayerhp = $playerhp - $creaturedamage;
echo "For " . $creaturedamage . " points of damage. <br>";
if ($newplayerhp < 1)
(
echo $playerinfo3['name'] . " has been killed<br>";
echo "<a href='gameover.php'>Continue";
exit;
)
$updateplayer="update players set hpoints='$newplayerhp' where name='player1'";
mysql_query($updateplayer) or die("Could not update player");
)
else
(
echo $creature . " misses!";
)
echo "<br><br><a href='battle.php?creatures=$creatures'>Battle Again!";
?>
Kieron
Re: issues with the tutorial
Hey,
you are not useless! These are good learnings.
You have an error
which references to the missing ';' on line 13,
as you can see, the $creature = $_GET['creature'] is missing an ;
you are not useless! These are good learnings.
You have an error
Code: Select all
Parse error: syntax error, unexpected ';' in C:\wamp\www\Tutorial\attack.php on line 13
as you can see, the $creature = $_GET['creature'] is missing an ;
Code: Select all
if (isset($_GET['creature']))
(
$creature=$_GET['creature'] <---- HERE
$creatureinfo="SELECT * from creatures where name = '$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
Why so serious?
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
Re: issues with the tutorial
Cheers,
When I insert that ;
It gives me the error of line 14, now
When I insert that ;
It gives me the error of line 14, now