Jump to content

PHP Parse Error - What am I doing wrong?

HamishJ's Photo
Posted Apr 13 2011 10:02 AM
3708 Views

Hi,

I'm new to PHP and am making my way through the excellent book by Robin Nixon. I decided to create an 'error message' screen to respond when connection with MYSQL could not be made. I wrote the following script:

<?php
require_once 'filename.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);

if (!$db_server) die("Unable to connect to MYSQL: " . mysql_error());
else echo "Welcome to MYSQL";

function mysql_fatal_error($msg)
{
$msg2 = mysql_error();
echo <<< _END
We are sorry but it was not possible to complete the required task.
The 'Error Message' we received was:

<p>$msg: $msg2"</p>

Please CLICK the BACK button on your browser and try again.
If you are still having problems please <a href="mailto:admin@server.com">email
our Administrator.</a>.

Thank you.
_END;
};
?>
________________________________________________________________________________________

When I went to the browser I got the following message back. What am I doing wrong - I have closed everything that is open (I think).

Parse error: syntax error, unexpected $end in C:\Program Files\EasyPHP-5.3.6.0\www\error_msg.php on line 28

________________________________________________________________________________________
If anyone can help I would appreciate it.

Thanks,

'H'

Tags:
0 Subscribe


1 Reply

0
  rjkreider's Photo
Posted May 20 2011 03:57 PM

I believe the error is to be somewhere in your included file:

require_once 'filename.php';
--
Rich Kreider