Thread: Add-On Releases - Yet Another Awards System
View Single Post
  #181  
Old 05-16-2009, 08:36 PM
cermi's Avatar
cermi cermi is offline
 
Join Date: Jun 2007
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by HolyKiller View Post
Fine mod, but i get one Warning if i giving avard to some user.

Code:
Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in [path]/adminpanel/award.php on line 581
Award is given, PM sended, everything looks fine, but that messages... i don't know what is wrong.

Thanks

Holy
The problem is in the mod source. The author "hardcoded" usage of (now deprecated, but that's not the point) mysql_insert_id(). But vB can use both mysql and mysqli API. And when you switch vB to new mysqli API, the problem appears:
  1. mysql_insert_id() is called without parameters, so it's supposed to take last opened mysql connection (opened from "old" mysql api)
  2. but there is no mysql connection, all connetions were opened by mysqli api
  3. "no worries!", says php, "we make new connections", so it tooks db credentials from php.ini and tries to make new connection
  4. but credentials in php.ini are usually empty, therefore the connection fails and mysql_insert_id() fails with it

Solution? I don't want to be rude, but hardcoding 1 api when vB is capable of running of 2 different APIs isn't the cleanest way. The cleanest way would be to use vB's build-in class and call some *insert_id() wrapped (if exists) or to dig the mysql(i) link object from vB's classes and use it directly in consideration of selected mysql API in vB conf. Or perhaps something better There are always many solutions to those kinds of problems.

But it's nice mod, anyway
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01061 seconds
  • Memory Usage 1,767KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete