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 :
the form is set up as following :
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 :
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
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
});
}
the form is set up as following :
<form action='UpdateClient.php' id='updateClientform' method="post" class="form-horizontal" role="form">
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();
}
?>
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good luck with it, and please post back if you have any questions, ~Ray
ASKER
Thanks again Ray, all up and running :-)
ASKER
Julian, thank you.. nearly forgot ;-)
ASKER
Perfect
You are welcome - thanks for the points
ASKER