vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   mysql_num_rows() expects parameter 1 to be resource (https://vborg.vbsupport.ru/showthread.php?t=311681)

el3reef 05-27-2014 12:41 AM

mysql_num_rows() expects parameter 1 to be resource
 
Hello,

i'm using query like that

$result = mysql_query("SELECT * FROM workshop_months_records where month_date LIKE '$month_date' limit 1");
$result_num_row = mysql_num_rows($result);

and this error return to me

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ..../includes/class_postbit.php(289) : eval()'d code on line 103

Although the plugin was work perfectly on version 3

waiting for help

thanks :)

kh99 05-27-2014 08:02 AM

I guess that would happen if the query failed. Change the code to something like:
Code:

$result = mysql_query("SELECT * FROM workshop_months_records where month_date LIKE '$month_date' limit 1");
if ($result)
{
  $result_num_row = mysql_num_rows($result);
  // etc
}

and see if the error goes away. I don't see anything wrong with the SQL, but it woul depend on the database including that table, and having $month_date set.

tbworld 05-27-2014 07:41 PM

At least that masks the initial error, but you are right @kh99, there was always a chance that the query could return a Boolean. :)

kh99 05-27-2014 08:43 PM

Yeah, you're right, I should have been more clear in saying that my "fix" is really only testing for FALSE to avoid the error, but doesn't fix the problem.

el3reef 05-27-2014 10:44 PM

the code work without problems in version 3 , and this error show white mysqli not mysql , so I expect that version 3 developed with mysqli , mysql_num_rows(); need $link parameter puls $result parameter , so i don't know how i can count the count of rows without the second parameter

--------------- Added [DATE]1401234837[/DATE] at [TIME]1401234837[/TIME] ---------------

i will tray $result = mysql_query("SELECT COUNT(*)
i hope it work


All times are GMT. The time now is 04:59 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.01009 seconds
  • Memory Usage 1,716KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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