Page 1 of 1

how to display success message for connection to db?

Posted: Tue Jun 22, 2010 3:45 pm
by iansane
Hi,

I'm working with a form and database and having troubles. The main issue is that I'm getting a blank white page with no errors. How can I tell php to output errors to let me know if I'm connecting to the database or not.

I have this

Code: Select all

$con = mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
But the problem is that I have other issues that are giving me a blank page and I want to see a success message not just a failed message. At least that way I know for certain that the connection is being made.

I tried this

Code: Select all

if (!$con){
$message = "no connection";
}
else{
$message = "success";
}
echo $message;
But still get the blank page. no failed or success message.

Re: how to display success message for connection to db?

Posted: Tue Jun 22, 2010 3:53 pm
by AbraCadaver
At the top:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');

Re: how to display success message for connection to db?

Posted: Tue Jun 22, 2010 4:26 pm
by iansane
Thank you abracadaver! I'm assuming that over rides settings in the php.ini file? Before I reinstalled everything, my last installation was already putting out these types of errors but since upgrading to Ubuntu 10.04 and the latest Ubuntu version of php the errors went away. Also I found several php.ini files in doing a system wide search to find out where it was and I wasn't sure which one to edit.

This is great though. I'll just put it at the top of all my pages and remove it when a page is complete.

Re: how to display success message for connection to db?

Posted: Tue Jun 22, 2010 4:46 pm
by iansane
Well now my title is misleading. Sorry about that.

So anyway, once I got my dbopen.php and dbclose.php working (thanks to the error messages that show now) I just put

Code: Select all

$message = "success";
at the end of the open and close files and echo it out in the main file to make absolutely certain it didn't just freeze up somewhere and give me a blank page.