vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Dang thing won't loop! (https://vborg.vbsupport.ru/showthread.php?t=29069)

TWTCommish 09-28-2001 05:17 AM

I'm working on a hack, and I am using code with the below format (in my main vB directory)...however, the query only produces one row, even though running it manually produces more than that. It seems as if it's not running through the loop more than once...any idea on what might be wrong with it? Thanks in advance. :)

PHP Code:

<?php
require("./global.php");

$forumlist $DB_site->query("SELECT * FROM forum WHERE displayorder != '0' AND active = '1' ORDER BY parentid, displayorder");
  while (
$forum $DB_site->fetch_array($forumlist)) {
    
// do stuff
  
}
$DB_site->free_result($forumlist);
unset(
$forum);

Could it be that those variables ($forumlist, $forum) are conflicting with some others in use in the global.php file?

JamesUS 09-28-2001 05:32 AM

Quite possibly. Try unsetting them both before your code:

PHP Code:

<?php
require("./global.php");

unset(
$forumlist);
unset(
$forum);
//your code here


TWTCommish 09-28-2001 05:38 AM

Good idea. Just tried it, but still no loopage. :(

TWTCommish 09-28-2001 08:32 PM

Alright, if someone can help me figure out what's wrong with this (seemingly) simple block of code, I'll give 'em a link in the footer of every page on my site (MovieForums.com) for 2 weeks (probably more...I'm lazy about taking stuff like that down). The site gets 150-200 posts a day on average.

Any assistance is appreciated! :)

Admin 09-28-2001 08:36 PM

Will you put *another* link to Israel.com if I help you? :D

j/k, I can't really understand why it won't loop. :confused:

TWTCommish 09-28-2001 09:04 PM

LOL...sure I would! Hehe. Yeah, I'm stumped to. It's really a very simple block of code. I ran the query elsewhere and it does indeed produce more than one record...the one that the script does spit out (by itself) each time is the last one returned when I run the query in phpMyAdmin...dunno if that's useful, though.

Dolby 09-28-2001 11:45 PM

I have a script that lists stuff... Look at this and insert your stuff and it should work for you.


PHP Code:

// echo "html that doesnt repeat";
$result=mysql_query("SELECT * FROM user where (usergroupid = '6' OR usergroupid ='8' OR usergroupid ='9') AND r_class = 'bard' order by username") or die ("Query Failed:".mysql_error());
while (
$row mysql_fetch_row($result)) {
    echo 
"//html that repeats... <tr><td width=200><a href=rprofile.php?ruser=$row[2]>$row[2] $row[42]</a></td><td>Lvl:$row[43]</td><td>$row[44]</td><td width=100>$row[46]</td></tr>
<tr><td colspan=4><hr size=1 width=100%></td></tr>"
;
}
// echo "html that doesnt repeat"; 


TWTCommish 09-29-2001 12:46 AM

Well, I have no problem grabbing data...I'm just sticking with vB's functions, because it's cleaner that way. I'm wondering if there is some quirk in the DB_site class that's preventing this loop from running properly.

JamesUS 09-29-2001 07:11 AM

Which version are you on Chris?

TWTCommish 09-29-2001 11:56 AM

Nope...this is with 2.0.3.

Wayne Luke 09-29-2001 02:21 PM

Sounds like a logic error in your //do stuff section that is causing it to break out of the loop.

If your loop works properly with a simplified //do stuff such as "echo '$forumlist[title]<br />';" then look at the logic there.

Also if you are appending strings like building a template. Make sure you are actually appending and not replacing. You might be missing some periods somewhere.

TWTCommish 09-29-2001 03:13 PM

Wayne was right, there was ONE character (a period) I was missing. Thanks, Wayne! What would you like the link to point to?

Wayne Luke 09-29-2001 04:27 PM

I don't need a link. Thanks though.

TWTCommish 09-29-2001 04:30 PM

Oh no, you deserve the thanks. :) I should've known it was a stupid oversight of mine, hehe. Anyway, the offer will stand for at least a couple weeks, so feel free to take me up on it later.

Thanks everyone for your time, I appreciate it.


All times are GMT. The time now is 02:08 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01998 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete