Battle.php (could not get player stats!)

Location of the Videos
Post Reply
m1steha
Posts: 9
Joined: Fri Oct 12, 2012 5:16 pm

Battle.php (could not get player stats!)

Post by m1steha »

If i go to /....battle.php it just shows me

could not get player stats!
Battle.php code is

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

$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!";

?>
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Battle.php (could not get player stats!)

Post by Jackolantern »

Have you verified every part of that query with your database? Have you tried running the query through phpMyAdmin? We have it pretty well narrowed down since the message you are getting is the die() message from the first couple lines of code, I believe (unless you have the same die() message used multiple times, which is not a good idea).
The indelible lord of tl;dr
ronislegend
Posts: 17
Joined: Mon Sep 24, 2012 8:33 pm

Re: Battle.php (could not get player stats!)

Post by ronislegend »

Is your players name 'player1', or should there be a variable $player1 ?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Battle.php (could not get player stats!)

Post by Jackolantern »

I am assuming the 'player1' is just a test he made while debugging his script since he is not setting up any variables. However, if that is supposed to be a variable, then I think you have probably found your issue :)
The indelible lord of tl;dr
m1steha
Posts: 9
Joined: Fri Oct 12, 2012 5:16 pm

Re: Battle.php (could not get player stats!)

Post by m1steha »

Not working!! any other ideas ??
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Battle.php (could not get player stats!)

Post by hallsofvallhalla »

change

Code: Select all

$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo)or die ("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
to

Code: Select all

$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo)or die (mysql_error());
$playerinfo3=mysql_fetch_array($playerinfo2);
then see what it says
Post Reply

Return to “Older Browser MMO Videos”