im trying for the first time to connect to a MySQL data with PHP 4 on a windows server. with linux, this is no problem. I know require_once does not work on windows version of PHP prior to 4.3, but im not sure if the server version is past that. here is the code i use to connect to a linux database, how is windows different?:
<?php # Script - mysql_connect.php
define ('DB_USER', 'x');
define ('DB_PASSWORD', 'x');
define ('DB_HOST', 'x');
define ('DB_NAME', 'x');
if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connection.
if (!mysql_select_db (DB_NAME)) { // If it can't select the database.
//Handle the error.
my_error_handler (mysql_errno(),
'Could not select the database: '
. mysql_error());
//Print a message to the user, kill the script.
echo '<p><font color="red">The site is currently experiencing technical difficulties. Our apologies.</font></p>';
include_once ('includes/footer.htm');
exit();
} //End of mysql_select_db IF.
} else { // If it couldn't connect to MySQL.
//Print a message to user, kill the script.
my_error_handler (mysql_errno(), 'Could not connect to the database: ' . mysql_error());
echo '<p><font color="red">The site is currently experiencing technical difficulties. Our apologies.</font></p>';
include_once ('includes/footer.htm');
exit();
} //End of $dbc IF.
//Function for escaping and trimming data.
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string (trim ($data), $dbc);
}
?>