error1.png
Always gets this error can someone help me please?Browser MMO Video #4
Re: Video #4
Always gets this error can someone help me please?
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Video #4
If you have the ID field set to auto-increment, take that out of your SQL insert statements. Also, in your VALUE brackets, don't start the list with a comma. A comma should only come after a value when you still have more to list.
The indelible lord of tl;dr
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Video #4
Please keep what up? Halls' video tutorials? I know he is planning on releasing some more videos soon.Bust wrote:Plz keep up
PLZZ
The indelible lord of tl;dr
Re: Video #4
iam having a problem evrey time i press attack it just says player's attack on the top plz helpthats the attack.php code
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 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?creature=$creature'>Battle Again!";
?>
Re: Video #4
nvm i made a mistake by not copyingMike9730 wrote:iam having a problem evrey time i press attack it just says player's attack on the top plz helpthats the attack.php codeCode: 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 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?creature=$creature'>Battle Again!"; ?>
Code: Select all
echo $playerinfo3['name'] . "'s Attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense. "<br>";
Re: Video #4
how do you make it so it dosent delete the creature?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video #4
keep watching the videos, the fix comes.
Re: Video #4
First I'd like to say these videos are really great and are kind of helping me along.
Second, I'd like to say that I have an error. I kind of had to go my own way with the attack script because I had a different idea for it to suit my game better.
But, being the beginner I am, I got an error and I have to limited of experience to fix it.
Parse error: parse error in C:\wamp\www\New Folder\attack.php on line 43
^^ Error
And yes, I did use Pokemon because I'm trying to make a Pokemon RPG
Second, I'd like to say that I have an error. I kind of had to go my own way with the attack script because I had a different idea for it to suit my game better.
But, being the beginner I am, I got an error and I have to limited of experience to fix it.
Parse error: parse error in C:\wamp\www\New Folder\attack.php on line 43
^^ Error
My not completely finished attack script.<?php
include 'connet.php';
$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die ("could not get player stats!");
$playerinfo3=mysql_fetch_arra($playerinfo2);
if (isset($_GET['pokemon']))
{
$pokemon=$_GET['pokemon'];
$pokemoninfo="SELECT * from pokemon where name = '$pokemon'";
$pokemoninfo2=mysql_query($pokemoninfo) or die("could not get the pokemon you were fighting!");
$pokemoninfo3=mysql_fetch_array($pokemoninfo2);
}
else
{
echo "<a href='battle.php'>No Pokemon selected. Go Back!";
exit;
}
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
$pokemonhp = $pokemoninfo3['hpoints'];
$pokemonattack = $pokemoninfo3['attack'];
$pokemondefense = $pokemoninfo3['defense'];
//Players Turn
echo "<u><i>playerinfo3['name']<br />['level']
$playerattack = {rand(1,15) * (2*$playerattack)) - ($pokemondefence);
if $playerattack < 1
{
echo 'Your attack misses!';
}
$newpokemonhp = $pokemonhp - $playerattack
if $newpokemonhp < 1
{
echo You have defeated this pokemon and made it faint <br />
<a href='battle.php'>Go Back;
exit;
}
$updatepokemon='update creatures set hpoints'='$newpokemonhp' where name='$pokemon';
mysql_query[$updatepokemon];
And yes, I did use Pokemon because I'm trying to make a Pokemon RPG

Re: Video #4
Or you can use my changes, that I made after asking that same question: http://indie-resource.com/forums/viewto ... =26&t=1353Mike9730 wrote:how do you make it so it dosent delete the creature?
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog