Aureole Posted November 10, 2007 Share Posted November 10, 2007 This should show 3 categories, it only shows 1. <?php // I will explicitly set the variable here to 1 for testing purposes in case it wasn't set correctly on the sign in page. $_SESSION['mem_access_level'] = 1; $query ="SELECT * FROM `categories` WHERE cat_access_level>='{$_SESSION['mem_access_level']}' AND cat_visible='1' ORDER BY cat_id"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { // Do stuff. } ?> I have 3 Categories with access levels of 1, 2 and 3. Only the 1st one is showing up. Any ideas? Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 10, 2007 Share Posted November 10, 2007 $query ="SELECT * FROM `categories` WHERE cat_access_level >= '{$_SESSION['mem_access_level']}' AND cat_visible = '1' ORDER BY cat_id"; try Quote Link to comment Share on other sites More sharing options...
Barand Posted November 10, 2007 Share Posted November 10, 2007 do they all have cat_visible = 1? Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 10, 2007 Author Share Posted November 10, 2007 Yes all three of them. I'm sorry to say your suggestion didn't make a difference either teng. ??? MYSQL eludes me sometimes. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 10, 2007 Share Posted November 10, 2007 try $query ="SELECT * FROM `categories` WHERE cat_access_level>='1' AND cat_visible='1' ORDER BY cat_id"; If that works then maybe you need to call session_start() first. Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 10, 2007 Author Share Posted November 10, 2007 I didn't post the entire file, session_start(); is the first thing to go at the top of all of my files. I will try it nonetheless. EDIT: Alas, that attempt was fruitless. Anyone else got an idea they'd like to throw in the pot? ??? Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 10, 2007 Author Share Posted November 10, 2007 Even this won't work, I'm beginning to feel an urge to slam my head against the desk several times, hmm. $query = "SELECT * FROM `categories` WHERE `cat_access_level` = '1' OR `cat_access_level` > '1' AND cat_visible = '1' ORDER BY `cat_id`"; The above actually shows no categories whatsoever. Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 10, 2007 Author Share Posted November 10, 2007 Get this. Upon 'uberly-debugging' I find that the query is returning 3 rows, so why isn't is showing them? $_SESSION['mem_access_level'] = 1; $query = "SELECT * FROM `categories` WHERE `cat_access_level` >= '1' AND cat_visible = '1' ORDER BY `cat_id`"; $result = mysql_query($query) or die(mysql_error()); $uberdebug = mysql_num_rows($result); echo $uberdebug; exit; ^ Returns 3. ??? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 10, 2007 Share Posted November 10, 2007 What happened to the while() loop you had in your first post? Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 10, 2007 Author Share Posted November 10, 2007 The while loop was after the exit; No worries I have solved my problem, it was so blatantly obvious staring me in the face. I name all my queries '$query', all my results '$result' etc. Apparently that caused interference, it's all fixed now. Thank you all for your help anyway. *Gives you a patience sticker* Quote Link to comment Share on other sites More sharing options...
eXeCuTeR Posted November 10, 2007 Share Posted November 10, 2007 Darn, I was just about to ask if you have multiple variables ^^ Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 10, 2007 Author Share Posted November 10, 2007 Ah well, maybe next time? Quote Link to comment 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.