The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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 !!! |
#2
|
||||
|
||||
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.
|
#3
|
|||
|
|||
Include the global.php file as Dan posted then simply use $DB_Site-> to connect to your database.
|
#4
|
|||
|
|||
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")); |
#5
|
||||
|
||||
Quote:
|
#6
|
|||
|
|||
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 !!! |
#7
|
||||
|
||||
Quote:
Read this |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|