Link to home
Start Free TrialLog in
Avatar of maddisoncr
maddisoncr

asked on

PHP Error Handling

I am having an issue with handling php errors within my program.

I have a form and i use the follow to call an update :

if ($("#updateClientform").valid())
{
				$.post($("#updateClientform").attr("action"),$("#updateClientform").serialize(),function(){
							
	if(('<?php echo $actionType?>') =="Add"){
		var alertText = "The Client has been succesfully Inserted !"
	}
	else if(('<?php echo $actionType?>') =="Edit"){
		var alertText = "The Client has been succesfully Updated !"
	}
	showAlert("success",alertText,"fieldset");
	window.scrollTo(0,0); //Scroll to top of screen after update
	});
}

Open in new window


the form is set up as following :

<form action='UpdateClient.php' id='updateClientform' method="post" class="form-horizontal" role="form">

Open in new window



This works well and without issue. It shows a bootstrap alert to say that it has happened.

The problem i have is that when there is an issue i don't know how to report it back to the calling page. I am guessing this is something very simple !!

This is the a summary of the PHP i am using :

<?php

	try
	{
		SQL and Binding....
		$result->execute();
	}
	
	catch (PDOException $e)
	{
		$output = 'Unable to update Client';
		include 'error.php';
		exit();	
	}	
	
?>

Open in new window



If there is an error i can only see by looking at a preview of the page. What i'd like is for the calling page to know that there was an error and then display the appropriate message

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maddisoncr
maddisoncr

ASKER

Thank you very much. I will have a look at all of these approaches over the weekend
Good luck with it, and please post back if you have any questions, ~Ray
Thanks again Ray, all up and running :-)
Julian, thank you.. nearly forgot ;-)
Perfect
You are welcome - thanks for the points