Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts

    2 While loops, one doesnt work

    Can someone tell me why both of these won't run on the same page? It only displays the second one.


    Code:
    function cheatlog()
    {
      $numbers = "50000000";
    	$page = '<center><p><b><u>If any users are listed below, it means they have cheats on their account.<br>Contact an administrator right away.</u></b><br /><br />';
    	$page .= '<hr>Number Cheat<hr><table width="50%">';
    	$result = doquery("SELECT number FROM {{table}} WHERE number > '$numbers' ORDER BY username", 'regusers');
    
    		$page .= '<tr><td><b>User Name</b></td><td><b>Number</b></td></tr>';
    
    		while($row = mysql_fetch_array($result))
                     {
    			$page .=  "<tr><td>".$row["username"]."</td><td>".$row["number"]."</td></tr>";
     }
    
        $page .= '</table></center>';
        
        $points = "5000";
    	$page = '<center><p><br /><br />';
    	$page .= '<hr>Points Cheat<hr><table width="50%">';
    	$ptsresult = doquery("SELECT points FROM {{table}} WHERE points > '$points' || maxpoints > '$points' ORDER BY username", 'regusers');
    
    		$page .= '<tr><td><b>User Name</b></td><td><b>Current Points</b></td><td><b>Maximum Points</b></td></tr>';
    
    		while($ptsrow = mysql_fetch_array($ptsresult))
                     {
    			$page .=  "<tr><td>".$ptsrow["username"]."</td><td>".$ptsrow["points"]."</td><td>".$ptsrow["maxpoints"]."</td></tr>";
    	}
    
        $page .= '</table></center>';
    
    
        display($mainpage, 'Cheat Log');
    }

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Comment the 2nd one out and see if the first one works then. If not there is buggy code in your first statement.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I'm guessing that there are no results from you're query. If you are on a local environment, or have PHPMyAdmin Access, filter that query into its sql string and run that through the direct sql entry.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    masterofollies (07-26-2008)

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Ok if I comment out the second while loop, the first one works perfect. But if I uncomment it, then the first one disappears. Regardless of entries, it should at least comes up with <hr>Number Cheat<hr> on the page.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Sorry, I missed this one: $page = '<center><p><br /><br />';.
    Should be $page .= .
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    masterofollies (07-26-2008)

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Hmmm seems we all missed it :O
    Wow that was strange

  • #7
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Ah yeah I've missed that before in scripts. It's possibly the smallest thing you can miss.

    I tested it and sure enough that was the problem. There was 2 missing the periods. Thanks Fou!

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    NP mate, I hate missing these .'s; they can take awhile to debug.
    I used to hear horror stories from back-in-the-day programmers. They spent weeks punching their cards out and placing them outside of their dormroom doors to have compiled and run, and a week later they get their results - Syntax error -_-. I'm glad I'm not from those days... lol.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    masterofollies (07-26-2008)

  • #9
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Wow seriously, that would be horrible.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •