Jump to content

Session Problems?


RDKL PerFecT

Recommended Posts

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

[code]
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";
             }
          }    
   }
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4076-session-problems/
Share on other sites

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.
[code]
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";
    }
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4076-session-problems/#findComment-14154
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.