![]() |
Adding queries the "right way"
I'm building a new front page (/index.php), and I need to understand the "right way" to add queries.
I include global.php, and have access to all my templates, etc. and it works fine. Now I want to add a query. Since I know just enough PHP to be dangerous, I first tried it using Dreamweaver MX. And it works, but I'm obviously opening an extra database connection, including files that I shouldn't etc. Here's what Dreamweaver created: Code:
<?php require_once('Connections/msfdev.php'); ?> Code:
<?php BTW, the particular query I'm doing selects the timestamp of the newest thread in my news forums, which are denoted by a field that I added to the db (newsforum="1"). As I said, it works fine as is, but I know that it's sloppy programming. |
try this:
PHP Code:
|
Thanks... that's exactly what I'm after, but it only "almost" works.
Problem is with the line: Code:
mysql_select_db($database_msfdev, $msfdev); |
Duh... RTFM, read the function description, deleted the line, and now it works.
Thanks. I've been looking for how to do this, couldn't find many refs with a search. I tried to figure out the $DB_site object, but wasn't having any luck. From the looks of it, I can just call it from anywhere, and it'll derive the connection info from vB. |
You're welcome ;)
the DB_site objects can be found in db_mysql.php in your admin directory |
All times are GMT. The time now is 12:32 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|