Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 05-11-2004, 12:23 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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'
Reply With Quote
  #2  
Old 05-11-2004, 12:32 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 05-11-2004, 12:51 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks xenon

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.
Reply With Quote
  #4  
Old 05-11-2004, 12:59 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because you have $num_rates and not $num_votes in the template?
Reply With Quote
  #5  
Old 05-11-2004, 01:07 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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

sorry
Reply With Quote
  #6  
Old 05-11-2004, 01:11 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We've all done it, many a time
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:40 PM.


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.04445 seconds
  • Memory Usage 2,215KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete