little problem....
little problem....
hey all,
i'm following hallsofvallhalla's tutorial to create a little Browser MMO..
which is kinda nice!
ok so i'm at the part 4b, and everything is right no error in the code and the page work...
but it seems as my creatures doesn't exist...
it say's "Player1" but do not say's creature name...............
i'm following hallsofvallhalla's tutorial to create a little Browser MMO..
which is kinda nice!
ok so i'm at the part 4b, and everything is right no error in the code and the page work...
but it seems as my creatures doesn't exist...
it say's "Player1" but do not say's creature name...............
A new Game Project has been started and is currently looking for coders & designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Here is the Topic: New Project
Or, just PM me if you're interested!
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: little problem....
we need to see your code
also I do not recommend doing the code until around video 14 but up to you.
also I do not recommend doing the code until around video 14 but up to you.
Re: little problem....
here is the code
Also,
the "Battle Again" is not there...
why do you recommend me to start codes around video 14?
Code: Select all
<?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 players 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'];
///////////////////player 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 creatures");
}
else
{
echo $playerinfo3['name'] . " misses!<br>";
}
////////////////////////////creature 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);
$newplayerehp = $playerehp - $creaturedamage;
echo "For " . $creaturedamage . " points of damage. <br>";
if ($newplayerehp < 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?creature=$creature>Battle Again!";
?>
the "Battle Again" is not there...
why do you recommend me to start codes around video 14?
A new Game Project has been started and is currently looking for coders & designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Here is the Topic: New Project
Or, just PM me if you're interested!
Re: little problem....
Code: Select all
$creatureinfo="SELECT * from players where name='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("Could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
Not sure how your DB is set up, but it should be something like this.
Code: Select all
$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);
Re: little problem....
Thank you Mark,
it works now.
But it still dont show up the "battle again" option.
it works now.
But it still dont show up the "battle again" option.
A new Game Project has been started and is currently looking for coders & designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Here is the Topic: New Project
Or, just PM me if you're interested!
Re: little problem....
Looks like you forgot a single quote.project69 wrote:Thank you Mark,
it works now.
But it still dont show up the "battle again" option.
Code: Select all
echo "<br><br><a href='battle.php?creature=$creature'>Battle Again!";
Re: little problem....
lol yeah..
but why should i start codes from video 14 only?
i miss all the starter things? So how can i add all things in my db if i skip this..
Also, i'm at Part 5 now and my login.php work but when i hit "Login" nothing happens...
heres my login.php code:
here is my authenticate.php code:
but why should i start codes from video 14 only?
i miss all the starter things? So how can i add all things in my db if i skip this..
Also, i'm at Part 5 now and my login.php work but when i hit "Login" nothing happens...
heres my login.php code:
Code: Select all
<from method="POST" action="authenticate.php">
Username: <input type="text" name="player" size="21">
Password: <input type="password" name="password" size="21" mask="x">
<br>
<input type="submit" value="Login" name="submit">
Code: Select all
<?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>";
}
}
?>
A new Game Project has been started and is currently looking for coders & designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Here is the Topic: New Project
Or, just PM me if you're interested!
Re: little problem....
You misspelled Form, and forgot to close the form.
Also on your authenticate, change
to
Code: Select all
<form method="POST" action="authenticate.php">
Username: <input type="text" name="player" size="21" />
Password: <input type="password" name="password" size="21" mask="x" />
<br>
<input type="submit" value="Login" name="submit" />
</form>
Code: Select all
$query = "select name,password from players where name='$player' and '$password'";
Code: Select all
$query = "select name,password from players where name='$player' and password='$password'";
Re: little problem....
thanks again...
the error was to change "form"...
the error was to change "form"...
A new Game Project has been started and is currently looking for coders & designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Here is the Topic: New Project
Or, just PM me if you're interested!
Re: little problem....
another error.
i'm at part 6 now and it says me:
why it says that my ";" is unexpected?
_______
Fixed
i've forgot ")"...
i really like these tutorials as it helps me to learn a little bit.
i'm at part 6 now and it says me:
the error is on this line:Parse error: syntax error, unexpected ';' in C:\wamp\www\tutorial\attack.php on line 75
$thirdmod = ($secondmod / 100 * $creatureinfo3['exper'];
Code: Select all
if ($playerinfo3['level'] > $creatureinfo3['level'])
{
$firstmod = $playerinfo3['level'] - $creatureinfo3['level'];
$secondmod = $firstmod * 10 ;
if ($secondmod > 90){$secondmod = 90;}
$thirdmod = ($secondmod / 100 * $creatureinfo3['exper'];
$totalexper =$creatureinfo3['exper'] - $thirdmod;
}
else
{
$firstmod = $creatureinfo3['level'] - $playerinfo3['level'];
$secondmod = $firstmod * 10 ;
if ($secondmod > 90){$secondmod = 90;}
$thirdmod = ($secondmod / 100 * $creatureinfo3['exper'];
$totalexper =$creatureinfo3['exper'] + $thirdmod;
}
echo "<br><br><big>You gain " . $totalexper . " experience.</br></big><br>";
$updateplayer="update players set exper=exper+'$totalexper' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
_______
Fixed
i've forgot ")"...
i really like these tutorials as it helps me to learn a little bit.
A new Game Project has been started and is currently looking for coders & designers.
Here is the Topic: New Project
Or, just PM me if you're interested!
Here is the Topic: New Project
Or, just PM me if you're interested!