Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.