vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Mysql query and result (https://vborg.vbsupport.ru/showthread.php?t=82180)

SilentK 05-28-2005 06:09 PM

Mysql query and result
 
PHP Code:

<?php
$reviews 
$DB_site->query_first("
        SELECT *
        FROM " 
TABLE_PREFIX "thread AS thread
        WHERE thread.forumid = 58 AND thread.visible = 1 AND thread.title like 'a%'
        ORDER BY dateline DESC
         "
);
$result mysql_query($sql);
$num_rows mysql_num_rows($result);

echo(
$num_rows " were found.<br>");
while(
$row mysql_fetch_array($result) )
{
     echo(
'<a href="http://www.xblteams.com/reviews.php?r=' $row[threadid] . '">' $reviews[title] . '</a><br />');
}
?>

When I load up the page that uses that code I get this error
Quote:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /./././././reviews.html on line 131
were found.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /./././././reviews.html on line 134
I am a noob when it comes to mysql queries so I am not exactly sure what's going on, if it's a problem with the query or the way I try to loop it.

*edit* I posted this over at vbulletin.com and was told it was caused by mixing vbulletin classes and php classes. I am not really familier with vbulletin classes so I could use some help. I was told that I should ask here.

Adrian Schneider 05-28-2005 06:24 PM

Change the query_first to just query. Then get rid of the $result = line... Then change any reference of $result to $reviews. Also change "$reviews[title]" to "$row[title]".

Paul M 05-28-2005 06:29 PM

Also change 'mysql_num_rows' to '$DB_site->num_rows' and 'mysql_fetch_array' to '$DB_site->fetch_array' :)

SilentK 05-28-2005 07:02 PM

Thanks, that fixed it.


All times are GMT. The time now is 03:36 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.01001 seconds
  • Memory Usage 1,722KB
  • 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_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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