Jump to content


Photo

Session Problems?


  • Please log in to reply
1 reply to this topic

#1 RDKL PerFecT

RDKL PerFecT
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 March 2006 - 11:25 AM

For some reason, whether logged in or not, this page echoes nothing.

include 'db.php';
if (isset($_SESSION['username'])) {
    $query = "SELECT Paid FROM partners WHERE gamertag='$username'";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
           foreach ($line as $col_value) {
             if ($col_value == "no") {

                include 'paypal1.html';
                echo "<br><br>Or alternatively, if you would like to pay for both and your partner, use the box below.<br>";
                include "paypal2.html";
             } else {
                echo "You've already paid";
             } 
          }     
   }
} 


#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 04 March 2006 - 02:25 PM

Hmm.. instead of using foreach, what happens if you say something like

if($line['paid']=="no") {
include......

Also, your while($line = mysql.... might be redundant. If you've only got one `gamertag` with that $username, you should be able to kill that while loop.

I've written it the way I'd do it... but I guessed 'paid' is the field you're using. You'll need to change the $line['paid'] to the correct field name.

Oh, and if it still doesn't work, you can try removing the "isset" parameter from the second line. Should work anyway. I'm also assuming that db.php has session_start() in it.
include 'db.php';
if (isset($_SESSION['username'])) {
    $query = "SELECT Paid FROM partners WHERE gamertag='$username'";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);
    if ($line['paid'] == "no") {
        include 'paypal1.html';
        echo "<br><br>Or alternatively, if you would like to pay for both and your partner, use the box below.<br>";
        include "paypal2.html";
    } else {
        echo "You've already paid";
    } 
} 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users