Hi All,
Just looking for some advice on a problem I'm having with a script I've created. I'm fairly new to PHP.
So I have a function which will create a log of an error and email it to me. In the case of an error occurring, I'd really like this to email me the error, report nothing to the user and then stop doing anything else. I'm using a MySQL DB so the code goes something like this:
$connection = connectToApiDatabase() or die("Could not connect to API database : " . mysql_error());
Which is fine. But obviously the prints to the screen. So I created a function called logServerSideError which emails me the error and prints nothing to the screen. I'm not sure however, how to call this function but then effectively stop my script like die/exit would. Probably a simple question but I can't find the answer!
$connection = connectToApiDatabase() or logServerSideError("Could not connect to API database : " . mysql_error());
mysql_select_db($db, $connection) or logServerSideError("Could not select API master database : " . mysql_error());
If either of those fail, obviously I don't want to carry on.
Thanks in advance for any help/advice.
Gareth.