My way of doing it (that's what she said):
Put this in the page where you want to query, ex. index.php:
PHP:
<?php require_once('mysqlconnect.php'); ?>
<?php mysql_select_db("your_db", $mysql);
$mysql_query = sprintf("SQL SYNTAX HERE");
$mysql_queried = mysql_query($mysql_query,$mysql) or die(mysql_error());
?>
Then put this in mysqlconnect.php and change it to 644 permissions (thanks rajat44)
PHP:
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
//Connect to server and select database.
$mysql = mysql_connect($host, $username, $password)or die("cannot connect to server");
?>
This way, the user/pass is only readable by the server. Also, you can use the "require_once" for every page, instead of copying user and pass to every page. Also, it's site-wide so when you change the MySQL server, you can change 1 file, and it's site-wide.
Hope this helps,
Josh