Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 06-30-2008, 06:59 PM
Cryo Cryo is offline
 
Join Date: Dec 2003
Location: Buffalo, NY
Posts: 197
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, misread it, it was a long and frustrating Saturday. Anyway, I figured the problem out... a different developer polluted the code with another DB connection because he didn't realize that the global.php included a database connection. Thanks though, and sorry for the little snap. Like I said, was a long Saturday. :erm:
Reply With Quote
  #12  
Old 09-11-2008, 09:02 PM
swellinfo swellinfo is offline
 
Join Date: May 2006
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am having the same error as Cryo, and if someone might have a suggestion on what could be wrong here I would be appreciative. I had been creating threads remotely using the build_new_post. I have since upgraded to 3.7.2, and that function does not work anymore. I have been trying to follow the instructions given in this thread, but running into the following error:

Fatal error: Database object is not an object in [path]/includes/class_dm.php on line 172

Here is my include file code that I call, when someone clicks to create a new thread:
PHP Code:
$cwd getcwd();
chdir('/home/swellinf/www/forum/');
require_once(
'global.php');
$adminid 1;
$forumid 13;

/*
define('VB_AREA', 'Forum');
define('CWD', (($getcwd = getcwd()) ? $getcwd : '.'));
require_once("./includes/init.php");

define('DIR', CWD);

require_once "./includes/functions.php"; 

*/

$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');

chdir($cwd);

$foruminfo fetch_foruminfo($forumid);
$threaddm->set_info('forum'$foruminfo);
$threaddm->set('forumid'$foruminfo['forumid']);
$threaddm->set('userid'$adminid);
$threaddm->set('title'$title);
$threaddm->set('pagetext'$message);
$threaddm->set('allowsmilie'1);
$threaddm->set('visible'1);
$threaddm->set('dateline'TIMENOW);
$threaddm->save();  

$threadid $threaddm->save(); 
The error occurs at this line:
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');

I am assuming there is something wrong with the $vbulletin object I am passing. Cryo mentioned something about an additional database connection that was messing things up. Is this something I need to check? I do open a connection to my non-forum database before I include the above file.

Any suggestions here?

Thank you.
Reply With Quote
  #13  
Old 09-12-2008, 09:59 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where are you using it in? If it is another PHP application, what is the variable for that application's database handle?
Reply With Quote
  #14  
Old 09-12-2008, 12:45 PM
swellinfo swellinfo is offline
 
Join Date: May 2006
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I am using it in another php file. I don't think I have a db handle variable.

I open my db connection, just with a:
mysql_select_db();

do you have any suggestions for me from here?
Reply With Quote
  #15  
Old 09-13-2008, 11:48 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So you have 2 database connections on the same page?
Reply With Quote
  #16  
Old 09-13-2008, 12:23 PM
swellinfo swellinfo is offline
 
Join Date: May 2006
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I open a DB connection before I include the file to build the new thread.

In the include file, I require_once(global.php). Does this create another db connection? If so, is this the problem. And, do you have suggestions for this?

Thanks again.
Reply With Quote
  #17  
Old 09-14-2008, 05:15 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you can call $vbulletin->db, you have no problem - but this is the problem, the DM doesn't detect that it is an object.

When opening your own connection, you need to assign a variable to the connection - an identifier. Then use this identifier in your own queries. See the PHP manual for more info.
Reply With Quote
  #18  
Old 09-15-2008, 03:19 PM
swellinfo swellinfo is offline
 
Join Date: May 2006
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My script looks something like this:

require_once('global.php');

then I get some user info from the $vbulletin object.

then I make a connection to the db like this:

$link = mysql_connect($host, $usr, $pass);
mysql_select_db($database, $link);

if ($_POST) { // the post vars pass info to create a thread remotedly
require('new_thread.php'); // this is the file i included in my first post

after the thread is created, the program goes on to make more sql db calls
}

then continues on to regular script.

Is there something I should be doing differently with the db connections?
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 06:37 PM.


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.04081 seconds
  • Memory Usage 2,229KB
  • 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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete