<?php # Script 6.5 - mysql_connect.php

// this file contains db connection info

//set db info as constants
define ('DB_USER', 'activetest');
define ('DB_PASSWORD', 'Daughters2');
define ('DB_HOST', 'activetest.db.3671394.hostedresource.com');
define ('DB_NAME', 'activetest');


//make connection and select DB
if($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) {

	if (!mysql_select_db (DB_NAME)) { //if it can't select DB
		
		my_error_handler (mysql_errno(), 'Could not select the database: ' . mysql_error());

		echo '<p><font color="red">This site is currently experiencing technical difficulties. We apologize for the 		inconvenience.</font></p>';
		//include_once ('footer.php');
		exit();
	} //end of mysql_select_db IF

} else {

	// print msg to user and kill script
	my_error_handler (mysql_errno(), 'Could not connect to database: ' . mysql_error());
	echo '<p><font color="red">This site is currently experiancing technical difficulties. We apologize for the 	inconvenience.</font></p>';
	//include_once ('footer.php');
	exit();

} //end of DB IF

// Function for escaping and trimming form data

function escape_data ($data) {
	global $dbc;
	if (ini_get('magic_quotes_gpc')) {
		$data = stripslashes($data);
	}
	return mysql_real_escape_string (trim ($data), $dbc);
} //end of escape_data function

?>