View Full Version : 2 While loops, one doesnt work

07-26-2008, 03:08 AM
Can someone tell me why both of these won't run on the same page? It only displays the second one.

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');

07-26-2008, 03:17 AM
Comment the 2nd one out and see if the first one works then. If not there is buggy code in your first statement.

07-26-2008, 03:33 AM
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.

07-26-2008, 03:51 AM
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.

07-26-2008, 06:49 AM
Sorry, I missed this one: $page = '<center><p><br /><br />';.
Should be $page .= .

07-26-2008, 12:55 PM
Hmmm seems we all missed it :O
Wow that was strange :(

07-26-2008, 03:13 PM
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!

07-26-2008, 08:19 PM
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.

07-26-2008, 11:22 PM
Wow seriously, that would be horrible.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum