Quests help

Location of the Videos
Post Reply
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Quests help

Post by dust1031 »

so i started coding a Quest system for my game, i set up the DB and coded the quest, and set up my 1st quest but when i go to Quests nothing comes up so its having trouble getting the information from the DB. Can someone please take a look.

quests.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
$bypass = 0;
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$id=$playerinfo3['id'];

 $questname = $playerinfo3['name'];
$level = $playerinfo3['level'];

$questinfo="SELECT * from quests where name='$questname'";
$questinfo2=mysql_query($questinfo) or die("could not  select quests!");
$questinfo3=mysql_fetch_array($questinfo2);

print "<center><h3>Quests</h3></center>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $selectquests="SELECT * from quests where pid='$id'";
      $selectquests2=mysql_query($selectquests) or die("could not select quests");
      print "<table border='1' bordercolor='black' bgcolor='#ffffff' >";
      print "<tr><td>Name<font color='ffffff'>_________________</td><td>Experience<font color='ffffff'>_</td><td>Gold<font color='ffffff'>_</td></tr>";
      while($selectquests3=mysql_fetch_array($selectquests2))

	   print "<tr><td>$selectquests3[name]</td><td>$selectquests3[exp]</td><td>$selectquests3[gold]</td></tr>";
this is what comes up when i click the quests link on the game

Image



this is what my quests DB looks like
Image

can someone please help me.
i hope the pictures uploaded right
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: Quests help

Post by Xaleph »

Your picture did not upload right.. :)
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: Quests help

Post by dust1031 »

Image

Image


did this work? i uploaded it via photobucket
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: Quests help

Post by dust1031 »

sorry for asking u to do this, but i see it still didnt upload right. but if u right click and click open image in new tab it will open correctly
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Quests help

Post by Jackolantern »

It looks like you are saving the player's name, and then looking for a quest that has that same name:

Code: Select all

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

$questname = $playerinfo3['name']; //why is this being saved into $questname?
$level = $playerinfo3['level'];

$questinfo="SELECT * from quests where name='$questname'"; //using the player name to find a similarly named quest
$questinfo2=mysql_query($questinfo) or die("could not  select quests!");
$questinfo3=mysql_fetch_array($questinfo2);
And looking at the quest table in your db, it doesn't look like any quest is going to have the same name as a player. That is likely why no quests are going to be found, since the name of your quest is "Starting out small".
The indelible lord of tl;dr
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: Quests help

Post by dust1031 »

ok i changed where it has $questname = $playerinfo3['name']; to $questname = $questinfo3['name']; but now it comes up an error that says Notice: Undefined variable: questinfo3 in C:\wamp\www\tutorial\quests.php on line 31
User avatar
62896dude
Posts: 516
Joined: Thu Jan 20, 2011 2:39 am

Re: Quests help

Post by 62896dude »

$questname has to come after you define $questinfo3 :)
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Quests help

Post by Jackolantern »

Did you change this line:

Code: Select all

$questname = $playerinfo3['name']; //why is this being saved into $questname?
$level = $playerinfo3['level'];
...to this?

Code: Select all

$questname = $questinfo3['name']; //why is this being saved into $questname?
$level = $playerinfo3['level'];
That isn't going to work because you actually run the quest info query and make the $questinfo3 variable below this in the code, which means it doesn't exist at the point you are trying to use it.

I think you are going to have to reconsider how you are making your quest system so far. Maybe try using the player's level to find the quest instead of the quest name? Something like this will work in that case:

Code: Select all

$questinfo="SELECT * from quests where level <= $level limit 1";
Or you will need to do something else to get the name of the quest. What that something else is depends on how you want players to find quests.
The indelible lord of tl;dr
claymore88
Posts: 10
Joined: Tue Aug 16, 2011 8:27 pm

Re: Quests help

Post by claymore88 »

you could select name from quest. and echo the column with row. and then make a quest info page and echo the rewards etc
Andrew
Posts: 16
Joined: Mon Aug 15, 2011 12:57 pm

Re: Quests help

Post by Andrew »

Hey could you please tell me how the database should look like in text since i can't open your pictures


Thanks,

Andrew
Post Reply

Return to “Older Browser MMO Videos”