| Mike Johnson 2004-11-30, 8:56 pm |
| From: Chris Payne [mailto:cjp@planetoxygene.com]=20
> I do have a final question, had a look online but couldn't find=20
> what I needed. It's hard to explain why, but basically=20
> individuals have my program on their HD, the DB is on their HD=20
> etc .... And it connects on startup to a remote server to check=20
> the latest version number so they can then download if a new=20
> one is available (Which I package using MS.net's installer=20
> system for distribution), Anyway, what I want to know is, how=20
> can I get a NICE error message IF they aren't connected to the=20
> net when they launch the software on their machine? Currently=20
> I get a nasty message, but I'd like to replace it with=20
> something like "Please make sure you are connected to the=20
> Internet" or something like that? I know the OR DIE command,=20
> but that doesn't work with connection failures.
I think what you're looking to do is suppress the PHP/DB error and
supply your own. What you want to do is preprend the db connection
function with `@' and add your own upon failure -- something like this:
<?
$dbh =3D @mysql_connect($dbhost, $dbuser, $dbpass);
if (!$dbh) {
echo "Please make sure you are connected to the Internet";
exit;
}
?>
The only problem with this is that it'll fail with the same error
message if their internet connection is fine but $dbhost is unavailable.
I'm not entirely certain if PHP can gracefully detect a local internet
connection, actually. For your purposes, though, this should do the job.
HTH!
--=20
Mike Johnson Smarter Living, Inc.
Web Developer www.smarterliving.com
mike@smarterliving.com (617) 886-5539
|