try ,catch with mysql_query
Posted: Mon May 12, 2008 11:55 am
hello! trying to test an old code and it happens that forthe code bellow i'am having the expected if i input wrong data.
i'll like to catch it by doing this
it catching alright but not displaying the custom message.it is from a form with PHP_SELF as action so it just displaying the same page no error this time but no message either.I can't understand that.any idea?
Code: Select all
if (!mysql_query($sql2,$con))
{
echo "There is a technical problem at this moment please contact live support" . mysql_error();
exit();
}
Code: Select all
try
{
mysql_query($sql2,$con);
}
catch(Exception $e)
{
echo "There is a technical problem at this moment please contact live support". $e->getMessage();
}