View Single Post
Old 05-16-2006, 1:09 AM   #4
weirfire
MK PitStop Member
 
weirfire's Avatar
 
Join Date: Mar 2006
Posts: 66
My Photos: ()
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $0.00
Donate

Recent Blog: None

weirfire will become famous soon enoughweirfire will become famous soon enough
Default

Well I personally built my own database connection functions which I use all the time.

They go like this;

// Function to open a database connection
function OpenDB(){
$dbh=mysql_connect ("localhost", "$username", "$password")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$db");

return $dbh;
}

// Function to close a database connection
function CloseDB($dbh){
mysql_close($dbh);
}

// Then I set an includes to the file with the function list as follows;
include 'includes/functions.php';

// Then I call my OpenDB function
$dbh = OpenDB();

// Then I run my mysql query and extract the data
$query = "SELECT * FROM table WHERE id >5";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){

$fieldname = $row['fieldname'];
$fieldname2 = $row['fieldname2'];

echo $fieldname . ' - ' . $fieldname2 . ' <br> ';

}

// Then I close the database
CloseDB($dbh);
__________________
web development Free diggs for your stories
bags of fashion - the latest in fashionable handbags
weirfire is offline   Reply With Quote