RDKL PerFecT Posted March 4, 2006 Share Posted March 4, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/4076-session-problems/ Share on other sites More sharing options...
michaellunsford Posted March 4, 2006 Share Posted March 4, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/4076-session-problems/#findComment-14154 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.