Everything seems wrong :S (Resolved)

Location of the Videos
Post Reply
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Everything seems wrong :S (Resolved)

Post by Huezzer »

Hey, everything seems wrong atm, I've got some serious problems with my game, every time I'm in the game, and try ''click'' any of the links it says '' can't do that'' etc. ''can't find'', Example: Equipment: Could not select backpack, Dunno what's wrong, can't travel eaither to other locations, Thanks, Hope you understad my problem, if not pls re-send a message, (By the way, When I login it doesn't show anything just a text: could ''not get arena''
Sorry if it's unreadable, (my text) :D

//Huezzer
Last edited by Huezzer on Fri Feb 18, 2011 10:53 am, edited 1 time in total.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Everything seems wrong :S

Post by Jackolantern »

We will need to see your code. We also probably need to look at just one problem at a time. Since the second issue ("not get arena") sounds like it is in one place, why not start there. It could have something to do with the other issue as well. Please post all the code related to the function of logging in and pulling up the arena or whatever it is that is messing up.
The indelible lord of tl;dr
User avatar
noswear
Posts: 18
Joined: Thu Jan 13, 2011 9:39 pm

Re: Everything seems wrong :S

Post by noswear »

From the looks of the errors, it seems that the problem has something to do with the database. Those errors are written when some querys fail to be executed, just check if all the db configs in the game match with the real database.
Image
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Re: Everything seems wrong :S

Post by Huezzer »

Here's my codes for the game: can't even login some times, it says all the time, wrong password of username, but I do type in right...

Battle.php

Code: Select all

<?php
include_once 'connect.php';
session_start();

include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">


<?php




if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$pllocation = $playerinfo3['location']; /// added line here.....


include_once 'statpanel.php';

$pid = $playerinfo3['id'];
$name = $playerinfo3['name'];
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];

?>
<div id="table">
<?php

if (isset($_GET['randid']))
{
   $randid=$_GET['randid'];
   $iteminfo="SELECT * from inventory where randid='$randid' AND id ='$pid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);

if (!$iteminfo3['name'])
{
}
else
{

$iname = $iteminfo3['name'];
$stats = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];

if ($type == "healing")
{
   $newhp = $statadd + $playerhp;
   if ($newhp > $playerinfo3['maxhp'])
   {
    $newhp = $playerinfo3['maxhp'];
   }
    $updateplayer="update players set hpoints='$newhp' where id='$pid'";
  mysql_query($updateplayer) or die("Could not update player");

    $updateitem="DELETE from inventory where id='$pid' AND randid='$randid' limit 1";
  mysql_query($updateitem) or die("Could not delete item");
   
   $playerhp = $newhp;
  
  echo "Used " . $iname . " and recovered " . $statadd . ".<br>";
}

}}





$creature = $playerinfo3['creature'];
if ($creature != 0)
{
$creatureinfo="SELECT * from creatures where id='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);

}
else
{
////////////////////new for video 20
$areaninfo="SELECT * from locations where location='$pllocation' AND type='arena'";
$areaninfo2=mysql_query($areaninfo) or die("could not get arena");
$areaninfo3=mysql_fetch_array($areaninfo2);
$arenalevel = $areaninfo3['level'];


  $creatureinfo="SELECT * from creatures where level <= '$arenalevel' order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die("could get a creature!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
$cid = $creatureinfo3['id'];
$updateplayer="update players set creature='$cid' where name='$name'";
  mysql_query($updateplayer) or die("Could not update player");
}

$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];



?>
</div>
<div id="player">
<?php
/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";
?>
</div>
<div id="creature">
<?php
///////creature info
echo "<u> " . $creatureinfo3['name'] . "</u><br>";
echo "Hit points = " . $creaturehp . "<br>";
echo "Attack = " . $creatureattack . "<br>";
echo "Defense = " . $creaturedefense . "<br><br><br>";

echo "<a href='attack.php'>Attack</a>";
echo "<br><a href='usemagic.php'>Use Magic</a>";
echo "<br><a href='useitem.php'>Use Item</a>";
echo "<br><a href='index.php'>Exit Arena</a>";


?>
</div>

<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>
Login.php

Code: Select all

<html>
<body background= "images/fire.jpg">
<form method="POST" action="authenticate.php">
<table height="600" width="500" align="center">
<tr>
  <td><center><font color="black">Username</font> <input type="text" name="player" size="21"></center><br>
<center><font color="black">Password</font> <input type="password" name="password" size="21" mask="x"></center><br><br><br><br>
<center><input type="submit" value="Login" name="submit"></center>
<br><br><center><font color="black">Not Registered?</font> <a href='register.php'>Register</td></center>
<div id="login"><div align="center"><img src="images/logo.gif" width="496" height="75" border="1" />
</tr>
</table>
</body>
</html>
Index.php

Code: Select all

<?php
include_once 'connect.php';
session_start();

include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">

<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
}
?>
</div>

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

$playerhp = $playerinfo3['hpoints'];
if ($playerhp < 1)
{
  echo "You are dead!" ;
  echo "<br><a href='useitem.php>Use an Item";
  exit;
}
////////////new for video 18
echo "<b><big><u>" . $playerinfo3['location'] . "</u></big></b><br>";
//////////////////////////

echo "<a href='store.php'>Visit Store</a><br><br>";
echo "<a href='weaponshop.php'>Visit Weapon Shop</a><br><br>";
echo "<a href='armorshop.php'>Visit Armor Shop</a><br><br>";
echo "<a href='inn.php'>Visit Inn</a><br><br>";
echo "<a href='spelltrainer.php'>Visit Spell Trainer</a><br><br>";
echo "<a href='battle.php'>Battle in Arena</a><br><br>";
//////////////////
///////////////////////


?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'></a>";
?>
</div>


My Game.php

Code: Select all

<?php include_once 'connect.php'; session_start();
// If you're not logged in, it immediately sends you to the homepage to log in.
if(!$_SESSION['player']){
    header('Location: ./index.php');
}

include_once 'logo.php';
$player = $_SESSION['player'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="style.css" rel="stylesheet" type="text/css" />
        <title>Tutorial MMORPG</title>
    </head>
    <body>

<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
 ?>
 <div id ="locations">
 <?php
$playerhp = $playerinfo3['hpoints'];
if ($playerhp < 1)
{
  echo "You are dead!" ;
  echo "<br><a href='useitem.php>Use an Item";
  exit;
}

if(isset($_GET['map']))
{
$bypass=1;
echo "<a href='game.php?mapchange=1&mapname=Crocania'>Crocania</a><br>";
echo "<a href='game.php?mapchange=1&mapname=Fordale Woods'>Fordale Woods</a><br>";
echo "<a href='game.php?mapchange=1&mapname=Mintus Mountains'>Mintus Mountains</a><br>";
}

if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];

$updateplayer="update players set location='$mapname' where name='$playerinfo3[name]'";
  mysql_query($updateplayer) or die("Could not update player");

echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='game.php'>To location</a><br>";
}

if ($bypass= 1)
{
echo "<b><big><u>" . $playerinfo3['location'] . "</u></big></b><br><br><br>";

echo "<a href='store.php'>Visit Store</a><br>";
echo "<a href='weaponshop.php'>Visit Weapon Shop</a><br>";
echo "<a href='armorshop.php'>Visit Armor Shop</a><br>";
echo "<a href='inn.php'>Visit Inn</a><br>";
echo "<a href='spelltrainer.php'>Visit Spell Trainer</a><br>";
echo "<a href='battle.php'>Battle in Arena</a><br>";
echo "<a href='game.php?map=1'>Go to Map</a><br>";
}


 ?>
 </div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'></a>";
?>
</div>
    </body>
</html>


Dunno if it's with the login thing to do(Game.php), but it's in game and that's the thing that I think doesn't work...
Thanks to all, // Huezzer :D By the way, I can't download the database file from: http://www.file-pasta.com/file/tutorial.zip in vidoe 10#, the website seems down... :P
NDest
Posts: 11
Joined: Tue Feb 01, 2011 12:43 pm

Re: Everything seems wrong :S

Post by NDest »

Did you actually named it "My Game.php"? or you were just saying my "Game.php"?
Last edited by NDest on Mon Feb 07, 2011 11:18 pm, edited 1 time in total.
NDest.
Onwer of
Image
a minecaft server
NDest
Posts: 11
Joined: Tue Feb 01, 2011 12:43 pm

Re: Everything seems wrong :S

Post by NDest »

oh and what program are you using to code? ConText?
NDest.
Onwer of
Image
a minecaft server
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Re: Everything seems wrong :S

Post by Huezzer »

Hey, yes I'm using ConText and I've named it just ''game.php'' and I found 1 more problem, in my phpadmin thing, I made a table named: Creatures, but I also had to make a new one called creature, 'cause the other one did dissapear, for example it says the table tutorial (8) but it's only 7 tables inside that show up, and when I try to creat a new table called creatureS, it says: It already exist.... Anyone know anything about it?, and hope you understad what I mean, Thanks


// Huezzer :D
NDest
Posts: 11
Joined: Tue Feb 01, 2011 12:43 pm

Re: Everything seems wrong :S

Post by NDest »

Well i would recommend you, to use netbeans, it helps a lot with code errors and about database, i could give you mine and you would import it but i dont know in what tutorial you are so it wouldnt help if you are ahead of me ...

Im on tutorial 16.
If you want the database just tell me and ill import to you

Sorry for my bad english

Regards,
NDest :P
NDest.
Onwer of
Image
a minecaft server
Post Reply

Return to “Older Browser MMO Videos”