Enjoy an ad free experience by logging in. Not a member yet?
Register .
07-26-2008, 02:08 AM
PM User |
#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');
}
07-26-2008, 02:17 AM
PM User |
#2
Senior Coder
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
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.
07-26-2008, 02:33 AM
PM User |
#3
God Emperor
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,751
Thanks: 4
Thanked 2,468 Times in 2,437 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:
07-26-2008, 02:51 AM
PM User |
#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.
07-26-2008, 05:49 AM
PM User |
#5
God Emperor
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,751
Thanks: 4
Thanked 2,468 Times in 2,437 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:
07-26-2008, 11:55 AM
PM User |
#6
Senior Coder
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
Hmmm seems we all missed it :O
Wow that was strange
07-26-2008, 02:13 PM
PM User |
#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!
07-26-2008, 07:19 PM
PM User |
#8
God Emperor
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,751
Thanks: 4
Thanked 2,468 Times in 2,437 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:
07-26-2008, 10:22 PM
PM User |
#9
Senior Coder
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
Wow seriously, that would be horrible.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 08:42 PM .
Advertisement
Log in to turn off these ads.