First off create an include file for your username, password and db to connect to.
That way you don't have to information in your php files for others to view.
I'm using /var/phpincludes as the directory for this example
So in /var/phpincludes create a file called info.inc
-- info.inc --
<?php
$hostname = "hostname";
$username = "username";
$password = "password";
$db = "database';
Now in your web directory (say /var/www/html)
create a file called index.php
--- index.php --
<?php
include("/var/phpincludes/info.inc");
$global_dbh = mysql_connect($hostname, $username, $password);
// if can't connect to db print error
if (!$global_dbh)
die("Cannot Connect to Database");
mysql_select_db($db, $global_dbh);
// now do a basic query
$select = "SELECT * from General";
$query = mysql_query($select) or die(mysql_error());
?>
THis does a basic select. Make sure you read http://www.php.net/manual for more information (they have a section for databases)
The SELECT query can be replaced with UPDATE, DELETE, INSERT etc...
That should give you a general idea on getting started.
BTW my example is based on MySQL