vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to use currect vB db connection? (https://vborg.vbsupport.ru/showthread.php?t=294208)

CoffeeLovesYou 01-21-2013 10:24 PM

How to use currect vB db connection?
 
Hi,

In all of my scripts, I have the mysql connection, as well as the selection of the mysql database.

However, the connection and the database is the same one defined in the vBulletin config.

My plugins are all using global_start.

How can I erase my db connection from my script to use the one vB is already using?

Sample script I am using:

PHP Code:

ob_start();
?>
<center><?php
//this is the same as my vBulletin's db connection info in config.php
$link mysql_connect("localhost","user","password");

mysql_select_db(databasename);
?>
 
<html>
<body>
 
<?php

$sql 
mysql_query("my query here");
//stuff here
echo "hi";
?>
</html></center>
<?php
   $countsrr 
ob_get_contents();
ob_end_clean();


Simon Lloyd 01-22-2013 03:35 AM

if you are running the queries from within vbulletin then you have an open connection to the database already and can just run your query, if they are scripts outside of vbulletin then maybe try
PHP Code:

require_once('./includes/config.php'); 


CoffeeLovesYou 01-22-2013 08:07 PM

Wow ,I feel like an idiot.
Removed my link and db select from the plugin and it's working like a charm.

Thanks!

Simon Lloyd 01-22-2013 09:13 PM

Its only ever easy if you know the answer :) - you're welcome!


All times are GMT. The time now is 05:02 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.01012 seconds
  • Memory Usage 1,715KB
  • 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
  • (2)bbcode_php_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