473,236 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

How do I get PHP5's Exception Handling to catch a fatal error?

Last weekend I decided to install
Apache 2.0.53-win32-x86-no_ssl
PHP 5.0.3
Smarty 2.6.7
MySQL essential-4.1.10-win32

I have Apache up (Port 80 blocked at the router and firewall!) and I
have got
Smarty working. I haven't got around to installing MySQL. I am now in
chapter 8 'Error and Exception Handling' of
"Beginning PHP 5 and MySQL: From Novice to Professional", by W. Jason
pub. Apress. I tried example Listing 8-1. Raising an Exception:
$smarty = new Smarty;

$smarty->template_dir='C:\php5\includes\smarty\templates\\ ';
$smarty->compile_dir='C:\php5\includes\smarty\templates_c\ \';

//Example 8.1
try {
$conn = mysql_connect("localhost1","webuser","secret");
if (! $conn) {
throw new Exception("Could not connect");
catch (Exception $e
) {
echo "Error (File: ".$e->getFile().", line ".$e->getLine()."):

Note that in the book, on the echo statement, the $e-> was missing from
getFile(). I went ahead and added it.

Cutting to the chase, when I ran the above nothing happened. I checked
log and saw the following:

[27-Feb-2005 11:33:59] PHP Fatal error: Call to undefined function
mysql_connect() in
C:\Program Files\Apache Group\Apache2\htdocs\example81.php on line 13

I commented out everything in the try block except the throw statement
reran. It worked as expected. How do I get PHP to catch fatal errors?

BTW, error_reporting = E_ALL

--Thank you,
--Mike Jr.

Jul 17 '05 #1
1 13630
Mike wrote:
How do I get PHP to catch fatal

You can only catch non-fatal errors. Fatal errors will always stop the
script because of their severity. Compare it with Java, which will stop
compiling when fatal errors occur...

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Mage | last post by:
Hello, def error_msg(msg): sys.exit(msg) try: do_something() if value != my_wish: error_msg('Invalid input')
by: cody | last post by:
public DateTime Value { get { try { return new DateTime(int.Parse(tbYear.Text), int.Parse(tbMonth.Text), int.Parse(tbDay.Text)); } catch (FormatException)
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
by: Dan Bass | last post by:
In a somewhat complex application, I've developed plug-in architecture and am having a problem as to when to catch general exceptions for logging purposes. In each plug-in class library, for...
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
by: Noor | last post by:
Hi all, I am trying to catch all types of exceptions from a app regardless of whether it is in debugger mode( VS development environment) or run the.exe file outside the IDE. My App...
by: ZorpiedoMan | last post by:
Well, I'm still wondering around in the "land of the lost exception"... It seems that controls that are bound to a class and the class throws an error in the SET method of the bound member, the...
by: Bry | last post by:
I've created a class that offers an enhanced way of handling fatal exceptions. The class allows the user to optionaly submit a http based anonymous error report to myself, and also records details...
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.