Em Segunda 09 Abril 2007 21:21, itoctopus escreveu:
> Use the @ in front of the statement and then check the result if it's
> valid.
>
> --
> itoctopus - http://www.itoctopus.com


I already use it, but I believe that try-catch would be _more_ useful...
With try-cath I can _get_ more errors instead with a if-then-else clasule...

i.e.: with if-then-else:

$connect=mysql_connect(...);

if($connect)
{
if(!(mysql_select_db(...,$connect)))
{
echo "Impossible select db.";
}
}
else
{
echo "Impossible connect to server.";
}

If I want to get some debug info, I put some mysql_error() and I get the error 
string and error code (mysql_errno()), but I believe that with exception I 
can get some useful error message without... hum... *critical* infos...

try
{
$connect=mysql_connect(...);
mysql_select_db(...,$connect);
}
catch (CONNECTION_EXCEPTION $e)
{
echo "Impossible connect: ".$e->get_message();
}
catch (SELECT_EXCEPTION $e)
{
echo "Impossible select db: ".$e->get_message();
}
catch (ANOTHER_USEFUL_EXCEPTION $e)
{
echo "another error: ".$e->get_message();
}
catch (Exception $e)
{
echo "Unknown error: ".$e->get_message();
}


I'm right?

TIA


-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
"Stanford women are responsible for the success of many Stanford men:
they give them "just one more reason" to stay in and study every night."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to