vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   help with while (https://vborg.vbsupport.ru/showthread.php?t=64991)

sabret00the 05-11-2004 11:23 AM

help with while
 
PHP Code:

             while ($project_info $DB_site->fetch_array($projects))
                  {
                  
$project_info['text'] = nl2br(stripslashes($project_info['text']));
                     
extract($project_info);
                  
$time_posted vbdate('n-j-y, g:i:s a'$timestamp);
  
//where it started going wrong
                  
$number_of_votes $DB_site->query_first("SELECT COUNT(*) 
                     FROM project_rate
                  WHERE projectid = 
$project_info[projectid]
                      "
);
                  
$num_votes number_format($DB_site->num_rows($number_of_votes)); 

can someone tell me what i'm doing wrong please? :nervous:

i'm now getting this error
Code:

Warning:  mysql_num_rows(): supplied argument is not a valid MySQL result resource in K:\Network\xampp\htdocs\forums\includes\db_mysql.php on line 311
i never touched that file btw it went ok untill i started trying to extract data from the second table.

'project_rate' as the project_info extracts data from 'projects'

Xenon 05-11-2004 11:32 AM

erm, you are running num_rows on a normal array (query_first's result is always an array, not a mysql result resource.

so the correcter version is:
PHP Code:

while ($project_info $DB_site->fetch_array($projects))
                  {
                 
$project_info['text'] = nl2br(stripslashes($project_info['text']));
                    
extract($project_info);
                 
$time_posted vbdate('n-j-y, g:i:s a'$timestamp);
  
//where it started going wrong
                 
$number_of_votes $DB_site->query_first("SELECT COUNT(*) AS votes
                    FROM project_rate
                 WHERE projectid = 
$project_info[projectid]
                      "
);
                 
$num_votes number_format($number_of_votes['votes']); 

but stillt a query within a while loop, is not good ;)

sabret00the 05-11-2004 11:51 AM

thanks xenon :D

i just tested this in phpmyadmin and it works fine, however in the project_bit template

HTML Code:

<table class="tborder" cellpadding="5" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
  <tr>
    <td class="tcat">
                project <a href="index.php?projectid=$projectid" class="projectid">$projectid</a> by confess[username]
    </td>
  </tr>
  <tr>
    <td valign="top" class="alt1">
                $text
        </td>
  </tr>
  <tr>
    <td class="thead" align="right">
                <smallfont><strong>$report $adminoptions $num_rates votes</strong></smallfont>
        </td>
  </tr>
</table>

it refuses to echo out.

NTLDR 05-11-2004 11:59 AM

Because you have $num_rates and not $num_votes in the template?

sabret00the 05-11-2004 12:07 PM

ahhhhhh, how stupid am i, i'm so so so so so sorry to waste your time :o

[high]* sabret00the is might ashamed and embarrassed
[/high]

sorry :o

NTLDR 05-11-2004 12:11 PM

We've all done it, many a time ;)


All times are GMT. The time now is 12:22 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.02123 seconds
  • Memory Usage 1,739KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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