Re: error for mysql

From: Date: Wed, 11 Oct 2000 02:24:09 +0000
Subject: Re: error for mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19467@lists.php.net to get a copy of this message
On Wed, 11 Oct 2000, Kurth Bemis wrote: > hey all > > have a feature that i'd like to add into scripts that querry a mysql table. > > i want to have it display a message like - cannot access database at this > time. please retry later. or something like that... > > i have a snippet...and am wondering how to integrate it with my existing > code..... > > function error ($err) { > echo "<h1>$err</h1><hr>"; > } > > script in here.. > > $fp = @fopen($file,"r"); > if(!$fp) { > print_error("Cannot open file: $file"); > break; > } > > How would i integrate that with this - > > $titleresult= mysql_query("SELECT * from validtables WHERE dbtables = > '$data'",$db); // sql query to get title and message info from db > > while ($myrow = @mysql_fetch_array($titleresult)) { // get the data from > the query and put it into vars > $title = $myrow["title"]; > $message1 = $myrow["message1"]; > $message2 = $myrow["message2"]; > $message3 = $myrow["message3"]; > } > > > any ideas? You would probably be better off attempting a database connection and returning an error message if that failed. Attempting to open a file will not tell you anything about the availability of a connection to mysql. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#19467) next »