Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 07-09-2015, 07:23 PM
kylek kylek is offline
 
Join Date: Oct 2003
Location: British Columbia, Canada
Posts: 798
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need php5 expert

I have an addon product that worked in php4 but we upgraded to php5 and most of it works except for 1 error showing at top of page. I have no knowledge of php but am trying to learn.

This is the error we are getting:

HTML Code:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean  given in /home/xxxx/xxx/pickem/includes/header.php on line  122
This is line 122 header.php:

HTML Code:
if (mysql_num_rows($query)) {
Using http://phpcodechecker.com/ I checked line 119 to line 129:

HTML Code:
$sql = "select * from " . $db_prefix . "users where userID = " . $user->userID;
$query = mysql_query($sql);

if (mysql_num_rows($query)) {
    $result = mysql_fetch_array($query);
        $template_name = $result['template_name'];
}

if (!empty($_POST['template_name'])) $template_name = $_POST['template_name'];

?>
Results:
Warning: There are 3 functions in your code that have been deprecated in the current version of PHP :
mysql_fetch_array()
mysql_num_rows()
mysql_query()

Any ideas on what may work?
Reply With Quote
  #2  
Old 07-09-2015, 07:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not a php5 expert. But, I see that mysql_query() can return FALSE in the case of an error, and since the error message says that $query is a boolean, I'd assume that's what's happening. You could just check for that in the 'if', like maybe:
Code:
if ($query !== FALSE && mysql_num_rows($query)) {
but I don't know what the error would be or what you would want to do in that case, so that may or may not be the way to handle it.

The mysql interface has been deprecated so you should change to one of the other interfaces, but you can ignore that for now.

ETA: Actually, if that plugin is depending on the database connection that vbulletin opens, and you've changed to using mysqli in the config.php, then the error could be that there's no database connection. In that case what you probably want to do is rewrite the plugin to use the vbulletin database functions (which isn't as difficult as it may sound since the functions are named mostly the same as the mysql functions). That will also take care of the deprecated interface issue.
Reply With Quote
2 благодарности(ей) от:
ForceHSS, Lynne
  #3  
Old 07-09-2015, 07:57 PM
kylek kylek is offline
 
Join Date: Oct 2003
Location: British Columbia, Canada
Posts: 798
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much kh99!!

I changed it to what you suggested and the error is gone now.
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:19 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05188 seconds
  • Memory Usage 2,179KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (2)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete