Re: MySQL Connectivity test

From: Date: Fri, 21 Sep 2001 01:49:13 +0000
Subject: Re: MySQL Connectivity test
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-68096@lists.php.net to get a copy of this message
On Fri, 21 Sep 2001 02:34, Jason Bell wrote: > Thanks lance and David for the reply. :) > > Yes, I suspected as much, *BUT* let me explain what I am trying to do: > > I have a script I am writing that uses a MySQL backend. I'm including > an initial configuration interface via the webbrowser. During initial > configuration, the user provides parameters for dbhost, dbname, dbpass > etc etc... > > If I simply try and connect, and it fails, I don't want my script to > error out, or even display an error... I just want it to move along and > let me deal with informing the user that his database configuration > does not work correctly. > > now, to do this, could I do something as simple as: > > $conntest = @mysql_connect($dbhost,$dbuser,$dbpass); > if ($conntest == "FALSE") { > // Do my "Oops didn't work stuff here" > } else { > // Continue with whatever it was I was doing. > } > > would that work as I expect it to? > > thanks! > > Jason > Here is what I use, called as an include file: <?php if(!mysql_connect("localhost", "user")): /* Return a message to the client and send mail to the administrator */ //Send mail, do page to client saying its broke exit; //Drop out and don't continue main script endif; //All ok continue with script ?> -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Don't ask me. The cats are in charge around here.

« previous php.general (#68096) next »