i need help with my store.php

Location of the Videos
Post Reply
maggnetic
Posts: 14
Joined: Sat Dec 31, 2011 2:44 am

i need help with my store.php

Post by maggnetic »

help me every time i go to my store an try to buy an item it tells me that in not login this is my store.php

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

?>
</div>
<div id="table">
 <?php
$creature = $_GET['creature'];
$counter = 0;




 echo "<small>";
      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%'>";
      $invinfo="SELECT * from store where amount > 0 ";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>____________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
      print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td>$invinfo3[price]</td><td><A href='buyitem.php?randid=$invinfo3[randid]'>Buy Item</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='battle.php?creature=$creature'>Go Back</center>";
            exit;
      }
  echo "<center><a href='battle.php?creature=$creature'>NeverMind</center></a>";
  
  ?>
  </div>

Mardonis
Posts: 139
Joined: Wed Jun 29, 2011 7:54 pm

Re: i need help with my store.php

Post by Mardonis »

Does this: include_once 'logo.php';

need to be this: include_once 'login.php';
overras
Posts: 91
Joined: Sun Oct 03, 2010 7:25 am

Re: i need help with my store.php

Post by overras »

session_start(); must be first defined. But , is enough to define it one time in connect.php, anyway try this:

Code: Select all

<?php
session_start();
include 'connect.php';
   include 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

?>
</div>
<div id="table">
 <?php
$creature = $_GET['creature'];
$counter = 0;




 echo "<small>";
      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%'>";
      $invinfo="SELECT * from store where amount > 0 ";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>____________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
      print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td>$invinfo3[price]</td><td><A href='buyitem.php?randid=$invinfo3[randid]'>Buy Item</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='battle.php?creature=$creature'>Go Back</center>";
            exit;
      }
  echo "<center><a href='battle.php?creature=$creature'>NeverMind</center></a>";
  
  ?>
  </div>
maggnetic
Posts: 14
Joined: Sat Dec 31, 2011 2:44 am

Re: i need help with my store.php

Post by maggnetic »

no its not a login its a logo
maggnetic
Posts: 14
Joined: Sat Dec 31, 2011 2:44 am

Re: i need help with my store.php

Post by maggnetic »

overras the code you gave me doesnt seem to work it does the samething
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: i need help with my store.php

Post by Callan S. »

So are you logging in with a log in script? And that doesn't give any errors? Does that log in script have 'session_start();' at the top of it?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: i need help with my store.php

Post by Jackolantern »

Have you checked to make sure that you are accessing exactly the same session variable that you set when you logged in. I did that tons of times before. $_SESSION['name'] in one, and $_SESSION['player'] in another and things like this.
The indelible lord of tl;dr
maggnetic
Posts: 14
Joined: Sat Dec 31, 2011 2:44 am

Re: i need help with my store.php

Post by maggnetic »

callan my login scipt doesnt have a session-start(), does it need to have it?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: i need help with my store.php

Post by hallsofvallhalla »

yeah make sure the session variable you are setting is called player and that the previous page is not unsetting it.
Post Reply

Return to “Older Browser MMO Videos”