Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-22-2004, 06:59 PM
DJ RRebel DJ RRebel is offline
 
Join Date: Jul 2002
Location: CANADA
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Connecting to MySQL database?

Heya guys ... I think I nee a bit of help here. I want to start a couple of hacks, but can't figure out the very basics of how vB connects to my database?

From what I've learned on my own, the way to connect is with a mysql_connect() or mysql_pconnect() function (which is better?). Since I can't find either anywhere, I'm assuming there's another method I'm not aware of.

That being said, I would think that whatever the command, it would use the $dbusername and $dbpassword variables set in the config.php file? Also that the $dbname variable would be used to identify the name of the database. I couldn't find any of these variables anywhere?


Is there really no need for this? Is there already some 'magical' (for lack of a better word .. lol) connection, and all I really need to do is use some 'require_once()' functions to include some vB page that has the connection info set into some usable variables already?

Or do I need to specify a connection command and a mysql_select_db($dbname); command? Followed by a:

$query_results = mysql_query("SELECT blablabla FROM table_xyz;");

Then use whatever HTML and various PHP looping/if/then statements needed, with the following to show what I wanted to show:

$rowdata = mysql_fetch_array($query_results);
echo htmlspecialchars(stripslashes($rowdata("column_nam e"));


Seems I've got the basics, but I'm not sure if it's all been set-up already in some way?

Anyhow ... any help getting me on track would be greatly appreciated !!! ... Hopefully I'll soon be able to add some quality hacks to this community !!!



Not sure if this is stuff already incorporated in vB that I can use, or just basic MySQL/PHP stuff ... feel free to move it to the PHP/MySQL forum if you feel it's more in that domain ... although I really hope there's something already incorporated into vB to access the database !!! lol

Thanks to all who take the time to get through this .. as you can see ... I'm slowly making progress !!!
Reply With Quote
  #2  
Old 09-22-2004, 07:17 PM
Dan's Avatar
Dan Dan is offline
 
Join Date: Dec 2002
Location: Titusville, Florida
Posts: 1,787
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the connection part is located in the global.php file and the config file from my knowledge so if you just include the global.php file in your new php page it should connect without anything else added.
Reply With Quote
  #3  
Old 09-22-2004, 08:02 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Include the global.php file as Dan posted then simply use $DB_Site-> to connect to your database.
Reply With Quote
  #4  
Old 09-22-2004, 08:07 PM
DJ RRebel DJ RRebel is offline
 
Join Date: Jul 2002
Location: CANADA
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

cool ... Thanks TONS !!! ... so all I need to worry about after that is the particular querie and what to do with it? Like as follows?


$query_results = mysql_query("SELECT column_a, column_b, column_c FROM table_xyz;");

Then use whatever HTML and various PHP looping/if/then statements needed, with the following to show what I wanted to show:

$rowdata = mysql_fetch_array($query_results);
echo htmlspecialchars(stripslashes($rowdata("column_nam e"));
Reply With Quote
  #5  
Old 09-22-2004, 08:38 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DJ RRebel
cool ... Thanks TONS !!! ... so all I need to worry about after that is the particular querie and what to do with it? Like as follows?


$query_results = mysql_query("SELECT column_a, column_b, column_c FROM table_xyz;");

Then use whatever HTML and various PHP looping/if/then statements needed, with the following to show what I wanted to show:

$rowdata = mysql_fetch_array($query_results);
echo htmlspecialchars(stripslashes($rowdata("column_nam e"));
Your better off making anything you want to show on the page into a varible and then displaying that varible inside of a template.
Reply With Quote
  #6  
Old 09-23-2004, 12:49 AM
DJ RRebel DJ RRebel is offline
 
Join Date: Jul 2002
Location: CANADA
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I know what you're getting at ... but how would I go abouts doing that?

I'm fairly confident I know how to create a template (done it a couple of years ago). But how would I go abouts calling the template from the php file?

Let's say I have a file getfunkydata.php

In that file, I would have to have:

require_once(global.php);

then:

- Call a master template that starts the introduction of the page and the start of a table where my results will be placed, as well as calls the header/footer templates. Then:

$query_results = mysql_query("SELECT column_a, column_b, column_c FROM table_xyz;");

- Start a loop for 0 to mysql_num_rows($query_results). Then within the loop have


$rowdata = mysql_fetch_array($query_results);

$col_a = htmlspecialchars(stripslashes($rowdata("column_a") );
$col_b = htmlspecialchars(stripslashes($rowdata("column_b") );
$col_c = htmlspecialchars(stripslashes($rowdata("column_c") );

- A call to a row formating template (that I'll have to create) which would include:
<tr><td>$col_a</td><td>$col_b</td><td>$col_c</td></tr>




I'm not too sure how the php page interacts with or call the templates?

seems to me, the looping data is linked from the templates in several "_bits" sub-templates, but I'm not sure how that is controled via the php page?


Anyhow .. you guys are REALLY helpful ... I think I'm actually starting to see the light at the end of the tunnel here !!!
Reply With Quote
  #7  
Old 09-23-2004, 01:27 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DJ RRebel
I think I know what you're getting at ... but how would I go abouts doing that?

I'm fairly confident I know how to create a template (done it a couple of years ago). But how would I go abouts calling the template from the php file?

Let's say I have a file getfunkydata.php

In that file, I would have to have:

require_once(global.php);

then:

- Call a master template that starts the introduction of the page and the start of a table where my results will be placed, as well as calls the header/footer templates. Then:

$query_results = mysql_query("SELECT column_a, column_b, column_c FROM table_xyz;");

- Start a loop for 0 to mysql_num_rows($query_results). Then within the loop have


$rowdata = mysql_fetch_array($query_results);

$col_a = htmlspecialchars(stripslashes($rowdata("column_a") );
$col_b = htmlspecialchars(stripslashes($rowdata("column_b") );
$col_c = htmlspecialchars(stripslashes($rowdata("column_c") );

- A call to a row formating template (that I'll have to create) which would include:
<tr><td>$col_a</td><td>$col_b</td><td>$col_c</td></tr>




I'm not too sure how the php page interacts with or call the templates?

seems to me, the looping data is linked from the templates in several "_bits" sub-templates, but I'm not sure how that is controled via the php page?


Anyhow .. you guys are REALLY helpful ... I think I'm actually starting to see the light at the end of the tunnel here !!!
https://vborg.vbsupport.ru/showthread.php?t=59939

Read this
Reply With Quote
Reply


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 12:24 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.10485 seconds
  • Memory Usage 2,224KB
  • 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
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete