GetReady Posted April 15, 2010 Share Posted April 15, 2010 Hey, basically something similar to this works to show the admin option on the menu on another site i have looked at code wise, Yet it doesnt want to work with mine, The active level is set to 4 and it still doesnt show what it should, belows the code, any help will help, Thanks. <? if ($active >= 4) { ?> <TR> <a class="nav" href="admin.php"><img class="nav" src="/images/admin.jpg" border="0"></a> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/ Share on other sites More sharing options...
smerny Posted April 15, 2010 Share Posted April 15, 2010 show where $active is being set? Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042697 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Yea, id missed that corrected it i believe getting an unexpected end error now... but i don't see why (still pretty new at php), The codes below if you have any ideas would be appreciated, Thanks. <? $sql="SELECT * from users WHERE username='$username' LIMIT 1"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ // Start looping table row $active = $rows['active']; ?> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> <TR> <? if (!$_SESSION['isLogined']){ }else{ setLastSeen($_SESSION['isLogined'],time()); $user=getusers($_SESSION['isLogined']); $userR=getUserRanks($_SESSION['isLogined']); ?> <? print date("\T\i\m\e: H:i"); ?> <br> <br> <a class="nav" href="base.php"><img class="nav" src="/images/profile.jpg" border="0"></a> <a class="nav" href="battlefield.php"><img class="nav" src="/images/ranks.jpg" border="0"></a> <TR> <a class="nav" href="attacklog.php"><img class="nav" src="/images/attacks.jpg" border="0"></a> <TR> <a class="nav" href="armory.php"><img class="nav" src="/images/items.jpg" border="0"></a> <TR> <a class="nav" href="train.php"><img class="nav" src="/images/train.jpg" border="0"></a> <TR> <a class="nav" href="intel.php"><img class="nav" src="/images/intel.jpg" border="0"></a> <TR> <a class="nav" href="soldiers.php"><img class="nav" src="/images/troops.jpg" border="0"></a> <TR> <a class="nav" href="crews.php"><img class="nav" src="/images/crew.jpg" border="0"></a> <TR> <a class="nav" href="inbox.php"><img class="nav" src="/images/mail.jpg" border="0"></a> <TR> <a class="nav" href="/chat/inex.php"><img class="nav" src="/images/chat.jpg" border="0"></a> <TR> <a class="nav" href="http://forums.doperunners.com."><img class="nav" src="/images/forums.jpg" border="0"></a> <TR> <a class="nav" href="logout.php"><img class="nav" src="/images/logout.jpg" border="0"></a> <? if ($active >= 4) { ?> <TR> <a class="nav" href="admin.php"><img class="nav" src="/images/admin.jpg" border="0"></a> <? } ?> <? } ?> </TBODY></TABLE> <P> <? if ($_SESSION['isLogined']){ ?> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> <TR> <TR> <TD class=menu_cell_repeater_vert style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px" vAlign=top align=middle><TABLE cellSpacing=0 cellPadding=3> <TBODY> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Rank:</TD> <TD style="FONT-SIZE: 8pt"> <? numecho ($userR->rank) ?> </TD> </TR> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Turns:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202><? numecho ($user->attackTurns) ?></FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Income:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202>$<? numecho (getUserIncome($user));?></FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Unit Production:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202><? numecho ($user->currentUnitProduction) ?> per 24 hours</FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>cash:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202> $<? numecho ($user->cash) ?> </FONT></TD> </TR> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Next Turn:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202> <? $nextTurnMin=getNextTurn($user); //$nextTurnMin=round($nextTurnMin/60); echo $nextTurnMin; ?> min</FONT></TD></TR> </FONT></TD></TR></TBODY></TABLE></TD></TR> <TR> <? } ?> <p> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> </td> </tr> </tbody></table> Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042713 Share on other sites More sharing options...
teamatomic Posted April 15, 2010 Share Posted April 15, 2010 You have not closed your while loop. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042715 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Sorry, Maybe im missing something here (as i say im new to php) <? $sql="SELECT * from users WHERE username='$username' LIMIT 1"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ // Start looping table row $active = $rows['active']; ?> does the ?> Not close the tag on that aspect? :s Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042720 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 It closed the tag, but not the } for the while loop. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042724 Share on other sites More sharing options...
oni-kun Posted April 15, 2010 Share Posted April 15, 2010 // Start looping table row You start the loop but don't end it as mentioned. <? Please use full delimiters, IE <?php as short tags are almost never compatible in practise. You're making the server guess if it's XML, ASP etc. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042727 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Thanks, Failed to see that, much appreciated, it fixed the error yet, the admin panel still isn't showing up, Rather confused to say the least, Anyone have a clue? Or am i going about it wrong :s Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042730 Share on other sites More sharing options...
TeddyKiller Posted April 15, 2010 Share Posted April 15, 2010 if ($active >= 4) Does that mean.. admin? If so.. try.. if ($active >= '4') Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042731 Share on other sites More sharing options...
oni-kun Posted April 15, 2010 Share Posted April 15, 2010 Thanks, Failed to see that, much appreciated, it fixed the error yet, the admin panel still isn't showing up, Rather confused to say the least, Anyone have a clue? Or am i going about it wrong :s I assume you've not error reporting on. ini_set('display_errors',1); error_reporting(E_ALL); This should tell you why the page is coming up blank (Not showing). Also you should put or die() statements on your SQL queries for debugging purposes: $result=mysql_query($sql) or die(mysql_error()); if ($active >= 4) Does that mean.. admin? If so.. try.. if ($active >= '4') Typecasting will make '4' and 4 the equivalent, It does not matter. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042733 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Ahhh Thanks for that the error is Notice: Undefined variable: username in /home/atrunn/public_html/testserver/left.php on line 6 The thing is the table is called username... so i fail to see why this would be an error :s Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042734 Share on other sites More sharing options...
teamatomic Posted April 15, 2010 Share Posted April 15, 2010 Right after you assign $active a value echo it out to see if it does in fact have a value. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042735 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Yea, i did <? echo "$active"; ?> and nothing came up so im assuming there's something wrong, I truly have no clue as to why, If anyone can enlighten me that would be great, If not its all good, Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042748 Share on other sites More sharing options...
TeddyKiller Posted April 15, 2010 Share Posted April 15, 2010 Might already been suggested. Where your query is $sql="SELECT * from users WHERE username='$username' LIMIT 1"; Below it, put echo $sql; What comes out? if a successful username appears in the query..then the problem is else where, in which I can't see. If a succesful username doesn't appear in the query, then bingo. You found your problem. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042750 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Yeap this is the problem, SELECT * from users WHERE username= Comes up, But im not sure as to why this is, all looks good to me? I mean username is under users... so im unsure as to why that is being shown. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042754 Share on other sites More sharing options...
trq Posted April 15, 2010 Share Posted April 15, 2010 Post your current code. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042756 Share on other sites More sharing options...
TeddyKiller Posted April 15, 2010 Share Posted April 15, 2010 "SELECT * from users WHERE username=" Theres no username in that? Lets say your logged in as.. bob. The query should display. "SELECT * from users WHERE username=bob" Does this not happen? Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042758 Share on other sites More sharing options...
GetReady Posted April 15, 2010 Author Share Posted April 15, 2010 Post your current code. As requested <? $sql="SELECT * from users WHERE username='$username'"; echo $sql; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ // Start looping table row } $active = $rows['active']; ?> <? ini_set('display_errors',1); error_reporting(E_ALL); ?> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> <TR> <? if (!$_SESSION['isLogined']){ }else{ setLastSeen($_SESSION['isLogined'],time()); $user=getusers($_SESSION['isLogined']); $userR=getUserRanks($_SESSION['isLogined']); ?> <? print date("\T\i\m\e: H:i"); ?> <br> <br> <a class="nav" href="base.php"><img class="nav" src="/images/profile.jpg" border="0"></a> <a class="nav" href="battlefield.php"><img class="nav" src="/images/ranks.jpg" border="0"></a> <TR> <a class="nav" href="attacklog.php"><img class="nav" src="/images/attacks.jpg" border="0"></a> <TR> <a class="nav" href="armory.php"><img class="nav" src="/images/items.jpg" border="0"></a> <TR> <a class="nav" href="train.php"><img class="nav" src="/images/train.jpg" border="0"></a> <TR> <a class="nav" href="intel.php"><img class="nav" src="/images/intel.jpg" border="0"></a> <TR> <a class="nav" href="soldiers.php"><img class="nav" src="/images/troops.jpg" border="0"></a> <TR> <a class="nav" href="crews.php"><img class="nav" src="/images/crew.jpg" border="0"></a> <TR> <a class="nav" href="inbox.php"><img class="nav" src="/images/mail.jpg" border="0"></a> <TR> <a class="nav" href="/chat/inex.php"><img class="nav" src="/images/chat.jpg" border="0"></a> <TR> <a class="nav" href="http://forums.doperunners.com."><img class="nav" src="/images/forums.jpg" border="0"></a> <TR> <a class="nav" href="logout.php"><img class="nav" src="/images/logout.jpg" border="0"></a> <? if ($active >= '4') { ?> <TR> <a class="nav" href="admin.php"><img class="nav" src="/images/admin.jpg" border="0"></a> <? } ?> <? } ?> </TBODY></TABLE> <P> <? if ($_SESSION['isLogined']){ ?> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> <TR> <TR> <TD class=menu_cell_repeater_vert style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px" vAlign=top align=middle><TABLE cellSpacing=0 cellPadding=3> <TBODY> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Rank:</TD> <TD style="FONT-SIZE: 8pt"> <? numecho ($userR->rank) ?> </TD> </TR> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Turns:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202><? numecho ($user->attackTurns) ?></FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Income:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202>$<? numecho (getUserIncome($user));?></FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Unit Production:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202><? numecho ($user->currentUnitProduction) ?> per 24 hours</FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>cash:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202> $<? numecho ($user->cash) ?> </FONT></TD> </TR> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Next Turn:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202> <? $nextTurnMin=getNextTurn($user); //$nextTurnMin=round($nextTurnMin/60); echo $nextTurnMin; ?> min</FONT></TD></TR> </FONT></TD></TR></TBODY></TABLE></TD></TR> <TR> <? } ?> <p> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> </td> </tr> </tbody></table> Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042759 Share on other sites More sharing options...
TeddyKiller Posted April 15, 2010 Share Posted April 15, 2010 while($rows=mysql_fetch_array($result)){ // Start looping table row } Shouldn't be closed here. The least you can do.. is this while($rows=mysql_fetch_array($result)){ // Start looping table row $active = $rows['active']; } Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042761 Share on other sites More sharing options...
GetReady Posted April 16, 2010 Author Share Posted April 16, 2010 while($rows=mysql_fetch_array($result)){ // Start looping table row } Shouldn't be closed here. The least you can do.. is this while($rows=mysql_fetch_array($result)){ // Start looping table row $active = $rows['active']; } Just updated it to this, still comes up with the same error, not username :'( Really, Really confused as to why this is the case. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042764 Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 Very untidy code. I moved the close brace of the while, to the bottom of the page. I can't understand the code.. but I'm assuming it should be down there? <? $sql="SELECT * from users WHERE username='$username'"; echo $sql; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ // Start looping table row $active = $rows['active']; ?> <? ini_set('display_errors',1); error_reporting(E_ALL); ?> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> <TR> <? if (!$_SESSION['isLogined']){ }else{ setLastSeen($_SESSION['isLogined'],time()); $user=getusers($_SESSION['isLogined']); $userR=getUserRanks($_SESSION['isLogined']); ?> <? print date("\T\i\m\e: H:i"); ?> <br> <br> <a class="nav" href="base.php"><img class="nav" src="/images/profile.jpg" border="0"></a> <a class="nav" href="battlefield.php"><img class="nav" src="/images/ranks.jpg" border="0"></a> <TR> <a class="nav" href="attacklog.php"><img class="nav" src="/images/attacks.jpg" border="0"></a> <TR> <a class="nav" href="armory.php"><img class="nav" src="/images/items.jpg" border="0"></a> <TR> <a class="nav" href="train.php"><img class="nav" src="/images/train.jpg" border="0"></a> <TR> <a class="nav" href="intel.php"><img class="nav" src="/images/intel.jpg" border="0"></a> <TR> <a class="nav" href="soldiers.php"><img class="nav" src="/images/troops.jpg" border="0"></a> <TR> <a class="nav" href="crews.php"><img class="nav" src="/images/crew.jpg" border="0"></a> <TR> <a class="nav" href="inbox.php"><img class="nav" src="/images/mail.jpg" border="0"></a> <TR> <a class="nav" href="/chat/inex.php"><img class="nav" src="/images/chat.jpg" border="0"></a> <TR> <a class="nav" href="http://forums.doperunners.com."><img class="nav" src="/images/forums.jpg" border="0"></a> <TR> <a class="nav" href="logout.php"><img class="nav" src="/images/logout.jpg" border="0"></a> <? if ($active >= '4') { ?> <TR> <a class="nav" href="admin.php"><img class="nav" src="/images/admin.jpg" border="0"></a> <? } ?> <? } ?> </TBODY></TABLE> <P> <? if ($_SESSION['isLogined']){ ?> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> <TR> <TR> <TD class=menu_cell_repeater_vert style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px" vAlign=top align=middle><TABLE cellSpacing=0 cellPadding=3> <TBODY> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Rank:</TD> <TD style="FONT-SIZE: 8pt"> <? numecho ($userR->rank) ?> </TD> </TR> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Turns:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202><? numecho ($user->attackTurns) ?></FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Income:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202>$<? numecho (getUserIncome($user));?></FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Unit Production:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202><? numecho ($user->currentUnitProduction) ?> per 24 hours</FONT></TD></TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>cash:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202> $<? numecho ($user->cash) ?> </FONT></TD> </TR> <TR> <TD style="FONT-SIZE: 8pt; COLOR: black" align=right>Next Turn:</TD> <TD style="FONT-SIZE: 8pt"><FONT color=#250202> <? $nextTurnMin=getNextTurn($user); //$nextTurnMin=round($nextTurnMin/60); echo $nextTurnMin; ?> min</FONT></TD></TR> </FONT></TD></TR></TBODY></TABLE></TD></TR> <TR> <? } ?> <p> <TABLE cellSpacing=0 cellPadding=0 width=137 border=0> <TBODY> </td> </tr> </tbody></table> <?php } ?> I'm off the sleep, so if this problem continues through tomorrow.. then I'll just open my eyes and sort it all out. Quote Link to comment https://forums.phpfreaks.com/topic/198696-any-ideas/#findComment-1042766 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.