Re: php die function for MySQL connection errors

From: Date: Sat, 14 Aug 2004 14:30:55 +0000
Subject: Re: php die function for MySQL connection errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193795@lists.php.net to get a copy of this message
John Gostick wrote:
Hi, I have a quick question about using the PHP die() function. I'm building a site around a MySQL database, and when I connect to the database from a PHP page I use the following code: $connection = mysql_connect($host, $user, $password) or die("Error connecting to SQL server"); $db = mysql_select_db($database, $connection) or die("'Error connecting to database"); you haven't told us what error messages you are getting - however my guess is that your header() call fails because of the error message produced by mysql_connect() if so you can try @mysql_connect($host, $user, $password) instead so that error messages to browser are suppressed ( you can achieve the same by editing your php.in)
-- Raditha Dissanayake. ------------------------------------------------------------------------ http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar.

« previous php.general (#193795) next »