I've written the following code to connect to my database, but its throwing up this error:
Parse error: syntax error, unexpected T_STRING in C:\xampp\mysql_connect.php on line 5
<?php # mysql_connect.php
// This file contains the database access information. It also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');
if ($dbc = my_sql_connect (DB_HOST, DB_USER, DB_PASSWORD))
{
// Make the connection.
// If it can't select the database.
if (!mysql_select_db (DB_NAME))
{
// Handle the error.
trigger_error("Could not select the database.\n<br />MySQL Error: " . mysql_error());
// Print a message to the user, include the footer, and stop the script.
include ('./includes/footer.html');
exit();
}
}
// If it couldn't connect to MySQL.
else
{
// Print a message to the user, include the footer and stop the script.
trigger_error("Could not connect to MySQL.\n<br />MySQL Error: " . mysql_error());
include ('./includes/footer.html');
exit();
}
// Create a function for escaping the data.
function escape_data ($data)
{
//Address Magic Quotes.
if (ini_get('magic_quotes_gpc'))
{
$data = stripslashes($data);
}
// Check for mysql_real_escape_string() support.
if (function_exists('mysql_real_escape_string'))
{
global $dbc;
$data = mysql_real_escape_string(trim($data), $dbc);
}
else
{
$data = mysql_real_escape_string(trin($data));
}
return $data;
}
?>
Does this mean there is a problem with the actual code I have typed? (i can't see any error) or is it a connection issue with the database?